23 #define _SVID_SOURCE // needed for MAP_ANONYMOUS
31 #if defined(MAP_ANON) && !defined(MAP_ANONYMOUS)
32 #define MAP_ANONYMOUS MAP_ANON
36 #define WIN32_LEAN_AND_MEAN
66 #define LICENSE_PREFIX "libswscale license: "
70 #define RET 0xC3 // near return opcode for x86
195 return "Unknown format";
202 return ((d * dist + c) * dist + b) * dist +
a;
205 b + 2.0 * c + 3.0 * d,
207 -b - 3.0 * c - 6.0 * d,
212 int *outFilterSize,
int xInc,
int srcW,
int dstW,
215 double param[2],
int is_horizontal)
222 int64_t *filter2 =
NULL;
223 const int64_t fone = 1LL << 54;
231 if (
FFABS(xInc - 0x10000) < 10) {
235 dstW *
sizeof(*filter) * filterSize, fail);
237 for (i = 0; i < dstW; i++) {
238 filter[i * filterSize] = fone;
246 dstW *
sizeof(*filter) * filterSize, fail);
248 xDstInSrc = xInc / 2 - 0x8000;
249 for (i = 0; i < dstW; i++) {
250 int xx = (xDstInSrc - ((filterSize - 1) << 15) + (1 << 15)) >> 16;
252 (*filterPos)[i] = xx;
256 }
else if ((xInc <= (1 << 16) && (flags &
SWS_AREA)) ||
262 dstW *
sizeof(*filter) * filterSize, fail);
264 xDstInSrc = xInc / 2 - 0x8000;
265 for (i = 0; i < dstW; i++) {
266 int xx = (xDstInSrc - ((filterSize - 1) << 15) + (1 << 15)) >> 16;
269 (*filterPos)[i] = xx;
271 for (j = 0; j < filterSize; j++) {
272 int64_t coeff = fone -
FFABS((xx << 16) - xDstInSrc) *
276 filter[i * filterSize + j] = coeff;
287 else if (flags &
SWS_X)
307 filterSize = 1 + sizeFactor;
309 filterSize = 1 + (sizeFactor * srcW + dstW - 1) / dstW;
311 filterSize =
FFMIN(filterSize, srcW - 2);
312 filterSize =
FFMAX(filterSize, 1);
315 dstW *
sizeof(*filter) * filterSize, fail);
317 xDstInSrc = xInc - 0x10000;
318 for (i = 0; i < dstW; i++) {
319 int xx = (xDstInSrc - ((filterSize - 2) << 16)) / (1 << 17);
321 (*filterPos)[i] = xx;
322 for (j = 0; j < filterSize; j++) {
323 int64_t d = (
FFABS(((int64_t)xx << 17) - xDstInSrc)) << 13;
329 floatd = d * (1.0 / (1 << 30));
331 if (flags & SWS_BICUBIC) {
335 if (d >= 1LL << 31) {
338 int64_t dd = (d * d) >> 30;
339 int64_t ddd = (dd * d) >> 30;
342 coeff = (12 * (1 << 24) - 9 * B - 6 * C) * ddd +
343 (-18 * (1 << 24) + 12 * B + 6 * C) * dd +
344 (6 * (1 << 24) - 2 * B) * (1 << 30);
346 coeff = (-B - 6 * C) * ddd +
347 (6 * B + 30 * C) * dd +
348 (-12 * B - 48 * C) * d +
349 (8 * B + 24 * C) * (1 << 30);
351 coeff *= fone >> (30 + 24);
354 else if (flags & SWS_X) {
355 double p = param ? param * 0.01 : 0.3;
356 coeff = d ? sin(d * M_PI) / (d * M_PI) : 1.0;
357 coeff *= pow(2.0, -p * d * d);
360 else if (flags & SWS_X) {
365 c = cos(floatd * M_PI);
372 coeff = (c * 0.5 + 0.5) * fone;
373 }
else if (flags & SWS_AREA) {
374 int64_t d2 = d - (1 << 29);
375 if (d2 * xInc < -(1LL << (29 + 16)))
376 coeff = 1.0 * (1LL << (30 + 16));
377 else if (d2 * xInc < (1LL << (29 + 16)))
378 coeff = -d2 * xInc + (1LL << (29 + 16));
381 coeff *= fone >> (30 + 16);
382 }
else if (flags & SWS_GAUSS) {
384 coeff = (pow(2.0, -p * floatd * floatd)) * fone;
385 }
else if (flags & SWS_SINC) {
386 coeff = (d ? sin(floatd * M_PI) / (floatd * M_PI) : 1.0) * fone;
387 }
else if (flags & SWS_LANCZOS) {
389 coeff = (d ? sin(floatd * M_PI) * sin(floatd * M_PI / p) /
390 (floatd * floatd * M_PI * M_PI / p) : 1.0) * fone;
393 }
else if (flags & SWS_BILINEAR) {
394 coeff = (1 << 30) - d;
398 }
else if (flags & SWS_SPLINE) {
399 double p = -2.196152422706632;
406 filter[i * filterSize + j] = coeff;
409 xDstInSrc += 2 * xInc;
416 assert(filterSize > 0);
417 filter2Size = filterSize;
419 filter2Size += srcFilter->
length - 1;
421 filter2Size += dstFilter->
length - 1;
422 assert(filter2Size > 0);
425 for (i = 0; i < dstW; i++) {
429 for (k = 0; k < srcFilter->
length; k++) {
430 for (j = 0; j < filterSize; j++)
431 filter2[i * filter2Size + k + j] +=
432 srcFilter->
coeff[k] * filter[i * filterSize + j];
435 for (j = 0; j < filterSize; j++)
436 filter2[i * filter2Size + j] = filter[i * filterSize + j];
440 (*filterPos)[i] += (filterSize - 1) / 2 - (filter2Size - 1) / 2;
447 for (i = dstW - 1; i >= 0; i--) {
448 int min = filter2Size;
450 int64_t cutOff = 0.0;
453 for (j = 0; j < filter2Size; j++) {
455 cutOff +=
FFABS(filter2[i * filter2Size]);
462 if (i < dstW - 1 && (*filterPos)[i] >= (*filterPos)[i + 1])
466 for (k = 1; k < filter2Size; k++)
467 filter2[i * filter2Size + k - 1] = filter2[i * filter2Size + k];
468 filter2[i * filter2Size + k - 1] = 0;
474 for (j = filter2Size - 1; j > 0; j--) {
475 cutOff +=
FFABS(filter2[i * filter2Size + j]);
482 if (min > minFilterSize)
488 if (minFilterSize < 5)
494 if (minFilterSize < 3)
500 if (minFilterSize == 1 && filterAlign == 2)
504 assert(minFilterSize > 0);
505 filterSize = (minFilterSize + (filterAlign - 1)) & (~(filterAlign - 1));
506 assert(filterSize > 0);
507 filter =
av_malloc(filterSize * dstW *
sizeof(*filter));
511 *outFilterSize = filterSize;
515 "SwScaler: reducing / aligning filtersize %d -> %d\n",
516 filter2Size, filterSize);
518 for (i = 0; i < dstW; i++) {
521 for (j = 0; j < filterSize; j++) {
522 if (j >= filter2Size)
523 filter[i * filterSize + j] = 0;
525 filter[i * filterSize + j] = filter2[i * filter2Size + j];
527 filter[i * filterSize + j] = 0;
535 for (i = 0; i < dstW; i++) {
537 if ((*filterPos)[i] < 0) {
539 for (j = 1; j < filterSize; j++) {
540 int left =
FFMAX(j + (*filterPos)[i], 0);
541 filter[i * filterSize + left] += filter[i * filterSize + j];
542 filter[i * filterSize + j] = 0;
547 if ((*filterPos)[i] + filterSize > srcW) {
548 int shift = (*filterPos)[i] + filterSize - srcW;
550 for (j = filterSize - 2; j >= 0; j--) {
551 int right =
FFMIN(j + shift, filterSize - 1);
552 filter[i * filterSize + right] += filter[i * filterSize + j];
553 filter[i * filterSize + j] = 0;
555 (*filterPos)[i] = srcW - filterSize;
563 *outFilterSize * (dstW + 3) *
sizeof(int16_t), fail);
566 for (i = 0; i < dstW; i++) {
571 for (j = 0; j < filterSize; j++) {
572 sum += filter[i * filterSize + j];
574 sum = (sum + one / 2) / one;
575 for (j = 0; j < *outFilterSize; j++) {
576 int64_t v = filter[i * filterSize + j] + error;
578 (*outFilter)[i * (*outFilterSize) + j] = intV;
579 error = v - intV * sum;
583 (*filterPos)[dstW + 0] =
584 (*filterPos)[dstW + 1] =
585 (*filterPos)[dstW + 2] = (*filterPos)[dstW - 1];
587 for (i = 0; i < *outFilterSize; i++) {
588 int k = (dstW - 1) * (*outFilterSize) + i;
589 (*outFilter)[k + 1 * (*outFilterSize)] =
590 (*outFilter)[k + 2 * (*outFilterSize)] =
591 (*outFilter)[k + 3 * (*outFilterSize)] = (*outFilter)[k];
602 #if HAVE_MMXEXT_INLINE
603 static int init_hscaler_mmxext(
int dstW,
int xInc,
uint8_t *filterCode,
632 "movq (%%"REG_d
", %%"REG_a
"), %%mm3 \n\t"
633 "movd (%%"REG_c
", %%"REG_S
"), %%mm0 \n\t"
634 "movd 1(%%"REG_c
", %%"REG_S
"), %%mm1 \n\t"
635 "punpcklbw %%mm7, %%mm1 \n\t"
636 "punpcklbw %%mm7, %%mm0 \n\t"
637 "pshufw $0xFF, %%mm1, %%mm1 \n\t"
639 "pshufw $0xFF, %%mm0, %%mm0 \n\t"
641 "psubw %%mm1, %%mm0 \n\t"
642 "movl 8(%%"REG_b
", %%"REG_a
"), %%esi \n\t"
643 "pmullw %%mm3, %%mm0 \n\t"
644 "psllw $7, %%mm1 \n\t"
645 "paddw %%mm1, %%mm0 \n\t"
647 "movq %%mm0, (%%"REG_D
", %%"REG_a
") \n\t"
649 "add $8, %%"REG_a
" \n\t"
664 :
"=r" (fragmentA),
"=r" (imm8OfPShufW1A),
"=r" (imm8OfPShufW2A),
665 "=r" (fragmentLengthA)
672 "movq (%%"REG_d
", %%"REG_a
"), %%mm3 \n\t"
673 "movd (%%"REG_c
", %%"REG_S
"), %%mm0 \n\t"
674 "punpcklbw %%mm7, %%mm0 \n\t"
675 "pshufw $0xFF, %%mm0, %%mm1 \n\t"
677 "pshufw $0xFF, %%mm0, %%mm0 \n\t"
679 "psubw %%mm1, %%mm0 \n\t"
680 "movl 8(%%"REG_b
", %%"REG_a
"), %%esi \n\t"
681 "pmullw %%mm3, %%mm0 \n\t"
682 "psllw $7, %%mm1 \n\t"
683 "paddw %%mm1, %%mm0 \n\t"
685 "movq %%mm0, (%%"REG_D
", %%"REG_a
") \n\t"
687 "add $8, %%"REG_a
" \n\t"
702 :
"=r" (fragmentB),
"=r" (imm8OfPShufW1B),
"=r" (imm8OfPShufW2B),
703 "=r" (fragmentLengthB)
709 for (i = 0; i < dstW / numSplits; i++) {
714 int b = ((xpos + xInc) >> 16) - xx;
715 int c = ((xpos + xInc * 2) >> 16) - xx;
716 int d = ((xpos + xInc * 3) >> 16) - xx;
717 int inc = (d + 1 < 4);
718 uint8_t *fragment = (d + 1 < 4) ? fragmentB : fragmentA;
719 x86_reg imm8OfPShufW1 = (d + 1 < 4) ? imm8OfPShufW1B : imm8OfPShufW1A;
720 x86_reg imm8OfPShufW2 = (d + 1 < 4) ? imm8OfPShufW2B : imm8OfPShufW2A;
721 x86_reg fragmentLength = (d + 1 < 4) ? fragmentLengthB : fragmentLengthA;
722 int maxShift = 3 - (d + inc);
726 filter[i] = ((xpos & 0xFFFF) ^ 0xFFFF) >> 9;
727 filter[i + 1] = (((xpos + xInc) & 0xFFFF) ^ 0xFFFF) >> 9;
728 filter[i + 2] = (((xpos + xInc * 2) & 0xFFFF) ^ 0xFFFF) >> 9;
729 filter[i + 3] = (((xpos + xInc * 3) & 0xFFFF) ^ 0xFFFF) >> 9;
730 filterPos[i / 2] = xx;
732 memcpy(filterCode + fragmentPos, fragment, fragmentLength);
734 filterCode[fragmentPos + imm8OfPShufW1] = (a + inc) |
738 filterCode[fragmentPos + imm8OfPShufW2] = a | (b << 2) |
742 if (i + 4 - inc >= dstW)
744 else if ((filterPos[i / 2] & 3) <= maxShift)
745 shift = filterPos[i / 2] & 3;
747 if (shift && i >= shift) {
748 filterCode[fragmentPos + imm8OfPShufW1] += 0x55 * shift;
749 filterCode[fragmentPos + imm8OfPShufW2] += 0x55 * shift;
750 filterPos[i / 2] -= shift;
754 fragmentPos += fragmentLength;
757 filterCode[fragmentPos] =
RET;
762 filterPos[((i / 2) + 1) & (~1)] = xpos >> 16;
764 return fragmentPos + 1;
776 int srcRange,
const int table[4],
int dstRange,
777 int brightness,
int contrast,
int saturation)
796 contrast, saturation);
801 contrast, saturation);
806 int *srcRange,
int **table,
int *dstRange,
807 int *brightness,
int *contrast,
int *saturation)
859 int usesVFilter, usesHFilter;
866 int dst_stride =
FFALIGN(dstW *
sizeof(int16_t) + 16, 16);
867 int dst_stride_px = dst_stride >> 1;
880 unscaled = (srcW == dstW && srcH == dstH);
904 if (!i || (i & (i - 1))) {
906 "Exactly one scaler algorithm must be chosen\n");
910 if (srcW < 4 || srcH < 1 || dstW < 8 || dstH < 1) {
914 srcW, srcH, dstW, dstH);
919 dstFilter = &dummyFilter;
921 srcFilter = &dummyFilter;
923 c->
lumXInc = (((int64_t)srcW << 16) + (dstW >> 1)) / dstW;
924 c->
lumYInc = (((int64_t)srcH << 16) + (dstH >> 1)) / dstH;
927 c->
vRounder = 4 * 0x0001000100010001ULL;
952 "full chroma interpolation for destination format '%s' not yet implemented\n",
982 if (unscaled && !usesHFilter && !usesVFilter &&
989 "using unscaled %s -> %s special converter\n",
1008 (srcW & 15) == 0) ? 1 : 0;
1013 "output width is not a multiple of 32 -> no MMXEXT scaler\n");
1030 if (flags & SWS_FAST_BILINEAR) {
1037 c->
lumXInc = ((int64_t)(srcW - 2) << 16) / (dstW - 2) - 20;
1042 #define USE_MMAP (HAVE_MMAP && HAVE_MPROTECT && defined MAP_ANONYMOUS)
1046 #if HAVE_MMXEXT_INLINE
1056 PROT_READ | PROT_WRITE,
1057 MAP_PRIVATE | MAP_ANONYMOUS,
1060 PROT_READ | PROT_WRITE,
1061 MAP_PRIVATE | MAP_ANONYMOUS,
1063 #elif HAVE_VIRTUALALLOC
1067 PAGE_EXECUTE_READWRITE);
1071 PAGE_EXECUTE_READWRITE);
1096 const int filterAlign =
1103 srcW, dstW, filterAlign, 1 << 14,
1105 cpu_flags, srcFilter->
lumH, dstFilter->
lumH,
1111 (flags & SWS_BICUBLIN) ? (flags |
SWS_BILINEAR) : flags,
1112 cpu_flags, srcFilter->
chrH, dstFilter->
chrH,
1120 const int filterAlign =
1126 c->
lumYInc, srcH, dstH, filterAlign, (1 << 12),
1133 filterAlign, (1 << 12),
1145 short *p = (
short *)&c->vYCoeffsBank[i];
1146 for (j = 0; j < 8; j++)
1152 short *p = (
short *)&c->vCCoeffsBank[i];
1153 for (j = 0; j < 8; j++)
1162 for (i = 0; i < dstH; i++) {
1163 int chrI = (int64_t)i * c->
chrDstH / dstH;
1190 dst_stride + 16, fail);
1198 dst_stride * 2 + 32, fail);
1206 dst_stride + 16, fail);
1212 memset(c->
chrUPixBuf[i], 64, dst_stride * 2 + 1);
1217 if (flags & SWS_FAST_BILINEAR)
1223 else if (flags &
SWS_X)
1267 "lum srcW=%d srcH=%d dstW=%d dstH=%d xInc=%d yInc=%d\n",
1270 "chr srcW=%d srcH=%d dstW=%d dstH=%d xInc=%d yInc=%d\n",
1281 #if FF_API_SWS_GETCONTEXT
1285 SwsFilter *dstFilter,
const double *param)
1303 c->
param[0] = param[0];
1304 c->
param[1] = param[1];
1320 float lumaSharpen,
float chromaSharpen,
1321 float chromaHShift,
float chromaVShift,
1328 if (lumaGBlur != 0.0) {
1336 if (chromaGBlur != 0.0) {
1344 if (chromaSharpen != 0.0) {
1353 if (lumaSharpen != 0.0) {
1362 if (chromaHShift != 0.0)
1365 if (chromaVShift != 0.0)
1395 const int length = (int)(variance * quality + 0.5) | 1;
1397 double middle = (length - 1) * 0.5;
1403 for (i = 0; i < length; i++) {
1404 double dist = i - middle;
1405 vec->
coeff[i] = exp(-dist * dist / (2 * variance * variance)) /
1406 sqrt(2 * variance * M_PI);
1422 for (i = 0; i < length; i++)
1438 for (i = 0; i < a->
length; i++)
1448 for (i = 0; i < a->
length; i++)
1449 a->
coeff[i] *= scalar;
1466 for (i = 0; i < a->
length; i++) {
1467 for (j = 0; j < b->
length; j++) {
1484 for (i = 0; i < a->
length; i++)
1501 for (i = 0; i < a->
length; i++)
1519 for (i = 0; i < a->
length; i++) {
1520 vec->
coeff[i + (length - 1) / 2 -
1571 for (i = 0; i < a->
length; i++)
1584 for (i = 0; i < a->
length; i++)
1585 if (a->
coeff[i] > max)
1588 for (i = 0; i < a->
length; i++)
1589 if (a->
coeff[i] < min)
1594 for (i = 0; i < a->
length; i++) {
1595 int x = (int)((a->
coeff[i] - min) * 60.0 / range + 0.5);
1596 av_log(log_ctx, log_level,
"%1.3f ", a->
coeff[i]);
1598 av_log(log_ctx, log_level,
" ");
1599 av_log(log_ctx, log_level,
"|\n");
1673 #elif HAVE_VIRTUALALLOC
1698 const double *
param)
1704 param = default_param;
1707 (context->
srcW != srcW ||
1708 context->
srcH != srcH ||
1710 context->
dstW != dstW ||
1711 context->
dstH != dstH ||
1713 context->
flags != flags ||
1714 context->
param[0] != param[0] ||
1715 context->
param[1] != param[1])) {
1732 context->
param[0] = param[0];
1733 context->
param[1] = param[1];
1737 context->
dstRange, 0, 1 << 16, 1 << 16);
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.
#define AV_PIX_FMT_BGR565
static const FormatEntry format_entries[AV_PIX_FMT_NB]
planar YUV 4:2:2, 18bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
ptrdiff_t uv_off_px
offset (in pixels) between u and v planes
void * av_malloc(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
av_cold void ff_yuv2rgb_init_tables_altivec(SwsContext *c, const int inv_table[4], int brightness, int contrast, int saturation)
static SwsVector * sws_sumVec(SwsVector *a, SwsVector *b)
void sws_freeVec(SwsVector *a)
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
int chrSrcH
Height of source chroma planes.
uint8_t * chrMmxextFilterCode
Runtime-generated MMXEXT horizontal fast bilinear scaler code for chroma planes.
planar YUV 4:2:0, 15bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
static int initFilter(int16_t **outFilter, int32_t **filterPos, int *outFilterSize, int xInc, int srcW, int dstW, int filterAlign, int one, int flags, int cpu_flags, SwsVector *srcFilter, SwsVector *dstFilter, double param[2], int is_horizontal)
const char * sws_format_name(enum AVPixelFormat format)
uint8_t * lumMmxextFilterCode
Runtime-generated MMXEXT horizontal fast bilinear scaler code for luma/alpha planes.
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
packed RGB 8:8:8, 24bpp, RGBRGB...
packed RGB 1:2:1 bitstream, 4bpp, (msb)1B 2G 1R(lsb), a byte contains two pixels, the first pixel in ...
#define AV_CPU_FLAG_ALTIVEC
planar YUV 4:4:4, 27bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
int av_get_bits_per_pixel(const AVPixFmtDescriptor *pixdesc)
Return the number of bits per pixel used by the pixel format described by pixdesc.
#define SWS_FAST_BILINEAR
void sws_convVec(SwsVector *a, SwsVector *b)
void av_opt_set_defaults(void *s)
Set the values of all AVOption fields to their default values.
int vChrDrop
Binary logarithm of extra vertical subsampling factor in source image chroma planes specified by user...
int ff_yuv2rgb_c_init_tables(SwsContext *c, const int inv_table[4], int fullRange, int brightness, int contrast, int saturation)
#define AV_PIX_FMT_BGR555
packed RGB 5:5:5, 16bpp, (msb)1A 5R 5G 5B(lsb), little-endian, most significant bit to 0 ...
static double getSplineCoeff(double a, double b, double c, double d, double dist)
int dstFormatBpp
Number of bits per pixel of the destination pixel format.
planar YUV 4:4:4 40bpp, (1 Cr & Cb sample per 1x1 Y & A samples, little-endian)
static int handle_jpeg(enum AVPixelFormat *format)
packed BGR 5:6:5, 16bpp, (msb) 5B 6G 5R(lsb), little-endian
planar YUV 4:2:0, 13.5bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
packed RGB 4:4:4, 16bpp, (msb)4A 4R 4G 4B(lsb), big-endian, most significant bits to 0 ...
int srcRange
0 = MPG YUV range, 1 = JPG YUV range (source image).
SwsFunc swScale
Note that src, dst, srcStride, dstStride will be copied in the sws_scale() wrapper so they can be fre...
planar YUV 4:2:0, 24bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
packed RGB 1:2:1 bitstream, 4bpp, (msb)1R 2G 1B(lsb), a byte contains two pixels, the first pixel in ...
Macro definitions for various function/variable attributes.
#define SWS_FULL_CHR_H_INT
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), little-endian
void sws_freeFilter(SwsFilter *filter)
int srcH
Height of source luma/alpha planes.
packed RGB 1:2:1, 8bpp, (msb)1B 2G 1R(lsb)
unsigned swscale_version(void)
Return the LIBSWSCALE_VERSION_INT constant.
planar YUV 4:2:0 22.5bpp, (1 Cr & Cb sample per 2x2 Y & A samples), little-endian ...
planar YUV 4:2:0 40bpp, (1 Cr & Cb sample per 2x2 Y & A samples, big-endian)
av_cold int sws_init_context(SwsContext *c, SwsFilter *srcFilter, SwsFilter *dstFilter)
Initialize the swscaler context sws_context.
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
int chrDstVSubSample
Binary logarithm of vertical subsampling factor between luma/alpha and chroma planes in destination i...
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
int length
number of coefficients in the vector
8 bit with PIX_FMT_RGB32 palette
packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as lit...
int vChrFilterSize
Vertical filter size for chroma pixels.
int16_t ** lumPixBuf
Ring buffer for scaled horizontal luma plane lines to be fed to the vertical scaler.
packed RGB 4:4:4, 16bpp, (msb)4A 4R 4G 4B(lsb), little-endian, most significant bits to 0 ...
packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), big-endian
packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
planar YUV 4:2:0 40bpp, (1 Cr & Cb sample per 2x2 Y & A samples, little-endian)
planar GBR 4:4:4 48bpp, big-endian
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of PIX_FMT_YUV440P and setting color_range ...
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV422P and setting color_...
planar YUV 4:4:4 64bpp, (1 Cr & Cb sample per 1x1 Y & A samples, big-endian)
external api for the swscale stuff
enum AVPixelFormat dstFormat
Destination pixel format.
void sws_freeContext(SwsContext *c)
Free the swscaler context swsContext.
int chrSrcHSubSample
Binary logarithm of horizontal subsampling factor between luma/alpha and chroma planes in source imag...
static av_always_inline int isYUV(enum AVPixelFormat pix_fmt)
static SwsVector * sws_getShiftedVec(SwsVector *a, int shift)
int32_t * vChrFilterPos
Array of vertical filter starting positions for each dst[i] for chroma planes.
int dstH
Height of destination luma/alpha planes.
planar YUV 4:2:0, 13.5bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
planar GBR 4:4:4 27bpp, big-endian
#define INLINE_MMX(flags)
planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
uint16_t depth_minus1
number of bits in the component minus 1
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
int sws_setColorspaceDetails(struct SwsContext *c, const int inv_table[4], int srcRange, const int table[4], int dstRange, int brightness, int contrast, int saturation)
SwsContext * sws_alloc_context(void)
Allocate an empty SwsContext.
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
int16_t ** chrVPixBuf
Ring buffer for scaled horizontal chroma plane lines to be fed to the vertical scaler.
int32_t * hChrFilterPos
Array of horizontal filter starting positions for each dst[i] for chroma planes.
planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
int hLumFilterSize
Horizontal filter size for luma/alpha pixels.
SwsFunc ff_getSwsFunc(SwsContext *c)
Return function pointer to fastest main scaler path function depending on architecture and available ...
void sws_scaleVec(SwsVector *a, double scalar)
Scale all the coefficients of a by the scalar value.
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
#define CONFIG_SWSCALE_ALPHA
#define SWS_SRC_V_CHR_DROP_MASK
planar YUV 4:4:4 36bpp, (1 Cr & Cb sample per 1x1 Y & A samples), big-endian
planar YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (firs...
void av_log(void *avcl, int level, const char *fmt,...)
planar YUV 4:2:2, 32bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
#define SWS_FULL_CHR_H_INP
SwsVector * sws_allocVec(int length)
Allocate and return an uninitialized vector with length coefficients.
int vChrBufSize
Number of vertical chroma lines allocated in the ring buffer.
av_cold void sws_rgb2rgb_init(void)
planar YUV 4:4:4 36bpp, (1 Cr & Cb sample per 1x1 Y & A samples), little-endian
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
int chrDstW
Width of destination chroma planes.
#define LIBAV_CONFIGURATION
packed RGB 16:16:16, 48bpp, 16B, 16G, 16R, the 2-byte value for each R/G/B component is stored as lit...
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
planar YUV 4:2:0 25bpp, (1 Cr & Cb sample per 2x2 Y & A samples, big-endian)
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
int32_t * hLumFilterPos
Array of horizontal filter starting positions for each dst[i] for luma/alpha planes.
int hChrFilterSize
Horizontal filter size for chroma pixels.
static void filter(MpegAudioContext *s, int ch, const short *samples, int incr)
ptrdiff_t uv_off_byte
offset (in bytes) between u and v planes
as above, but U and V bytes are swapped
int dstRange
0 = MPG YUV range, 1 = JPG YUV range (destination image).
packed RGB 1:2:1, 8bpp, (msb)1R 2G 1B(lsb)
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV420P and setting color_...
uint8_t * formatConvBuffer
#define INLINE_AMD3DNOW(flags)
SwsVector * sws_getGaussianVec(double variance, double quality)
Return a normalized Gaussian curve used to filter stuff quality = 3 is high quality, lower is lower quality.
int vLumBufSize
Number of vertical luma/alpha lines allocated in the ring buffer.
int16_t ** chrUPixBuf
Ring buffer for scaled horizontal chroma plane lines to be fed to the vertical scaler.
int sws_getColorspaceDetails(struct SwsContext *c, int **inv_table, int *srcRange, int **table, int *dstRange, int *brightness, int *contrast, int *saturation)
SwsFilter * sws_getDefaultFilter(float lumaGBlur, float chromaGBlur, float lumaSharpen, float chromaSharpen, float chromaHShift, float chromaVShift, int verbose)
void sws_printVec2(SwsVector *a, AVClass *log_ctx, int log_level)
Print with av_log() a textual representation of the vector a if log_level <= av_log_level.
planar YUV 4:4:4 40bpp, (1 Cr & Cb sample per 1x1 Y & A samples, big-endian)
planar YUV 4:2:2 27bpp, (1 Cr & Cb sample per 2x1 Y & A samples), big-endian
const char * swscale_configuration(void)
Return the libswscale build-time configuration.
packed RGB 8:8:8, 24bpp, BGRBGR...
planar YUV 4:2:0, 15bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
enum AVPixelFormat pix_fmt
struct SwsContext * sws_getCachedContext(struct SwsContext *context, int srcW, int srcH, enum AVPixelFormat srcFormat, int dstW, int dstH, enum AVPixelFormat dstFormat, int flags, SwsFilter *srcFilter, SwsFilter *dstFilter, const double *param)
Check if context can be reused, otherwise reallocate a new one.
SwsVector * sws_getConstVec(double c, int length)
Allocate and return a vector with length coefficients, all with the same value c. ...
int srcColorspaceTable[4]
int dstW
Width of destination luma/alpha planes.
planar YUV 4:2:2, 18bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
packed RGB 16:16:16, 48bpp, 16B, 16G, 16R, the 2-byte value for each R/G/B component is stored as big...
packed BGR 5:6:5, 16bpp, (msb) 5B 6G 5R(lsb), big-endian
int32_t * vLumFilterPos
Array of vertical filter starting positions for each dst[i] for luma/alpha planes.
packed RGB 3:3:2, 8bpp, (msb)2B 3G 3R(lsb)
double * coeff
pointer to the list of coefficients
planar YUV 4:2:0, 24bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
int dstColorspaceTable[4]
void(* rgb15to16)(const uint8_t *src, uint8_t *dst, int src_size)
const AVClass * av_class
info on struct for av_log
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
planar GBR 4:4:4 30bpp, big-endian
#define SWS_PARAM_DEFAULT
planar YUV 4:2:2 48bpp, (1 Cr & Cb sample per 2x1 Y & A samples, big-endian)
int chrDstH
Height of destination chroma planes.
void sws_normalizeVec(SwsVector *a, double height)
Scale all the coefficients of a so that their sum equals height.
packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr
static void getSubSampleFactors(int *h, int *v, enum AVPixelFormat format)
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
planar YUV 4:2:2 48bpp, (1 Cr & Cb sample per 2x1 Y & A samples, little-endian)
static SwsVector * sws_diffVec(SwsVector *a, SwsVector *b)
int lumMmxextFilterCodeSize
Runtime-generated MMXEXT horizontal fast bilinear scaler code size for luma/alpha planes...
Describe the class of an AVClass context structure.
planar YUV 4:4:4 64bpp, (1 Cr & Cb sample per 1x1 Y & A samples, little-endian)
SwsVector * sws_getIdentityVec(void)
Allocate and return a vector with just one coefficient, with value 1.0.
int vLumFilterSize
Vertical filter size for luma/alpha pixels.
#define ROUNDED_DIV(a, b)
void sws_shiftVec(SwsVector *a, int shift)
int chrMmxextFilterCodeSize
Runtime-generated MMXEXT horizontal fast bilinear scaler code size for chroma planes.
planar YUV 4:2:0 22.5bpp, (1 Cr & Cb sample per 2x2 Y & A samples), big-endian
packed BGR 5:5:5, 16bpp, (msb)1A 5B 5G 5R(lsb), little-endian, most significant bit to 1 ...
#define SWS_SRC_V_CHR_DROP_SHIFT
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.
int16_t * hLumFilter
Array of horizontal filter coefficients for luma/alpha planes.
void sws_subVec(SwsVector *a, SwsVector *b)
planar YUV 4:2:2 30bpp, (1 Cr & Cb sample per 2x1 Y & A samples, little-endian)
packed RGB 5:5:5, 16bpp, (msb)1A 5R 5G 5B(lsb), big-endian, most significant bit to 0 ...
packed BGR 4:4:4, 16bpp, (msb)4A 4B 4G 4R(lsb), big-endian, most significant bits to 1 ...
planar YUV 4:4:4, 27bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
const char * swscale_license(void)
Return the libswscale license.
const AVClass sws_context_class
Y , 1bpp, 0 is black, 1 is white, in each byte pixels are ordered from the msb to the lsb...
#define INLINE_MMXEXT(flags)
static double sws_dcVec(SwsVector *a)
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
double param[2]
Input parameters for scaling algorithms that need them.
Y , 1bpp, 0 is white, 1 is black, in each byte pixels are ordered from the msb to the lsb...
#define FF_ALLOC_OR_GOTO(ctx, p, size, label)
int sws_isSupportedOutput(enum AVPixelFormat pix_fmt)
Return a positive value if pix_fmt is a supported output format, 0 otherwise.
planar GBR 4:4:4 27bpp, little-endian
packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as big...
#define SWS_MAX_REDUCE_CUTOFF
enum AVPixelFormat srcFormat
Source pixel format.
planar YUV 4:2:2, 32bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV444P and setting color_...
packed RGB 3:3:2, 8bpp, (msb)2R 3G 3B(lsb)
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
SwsVector * sws_cloneVec(SwsVector *a)
Allocate and return a clone of the vector a, that is a vector with the same coefficients as a...
planar YUV 4:2:0 25bpp, (1 Cr & Cb sample per 2x2 Y & A samples, little-endian)
int srcFormatBpp
Number of bits per pixel of the source pixel format.
Y , 16bpp, little-endian.
struct FormatEntry FormatEntry
SwsContext * sws_getContext(int srcW, int srcH, enum AVPixelFormat srcFormat, int dstW, int dstH, enum AVPixelFormat dstFormat, int flags, SwsFilter *srcFilter, SwsFilter *dstFilter, const double *param)
Allocate and return an SwsContext.
planar YUV 4:2:2 30bpp, (1 Cr & Cb sample per 2x1 Y & A samples, big-endian)
packed BGR 5:5:5, 16bpp, (msb)1A 5B 5G 5R(lsb), big-endian, most significant bit to 1 ...
number of pixel formats, DO NOT USE THIS if you want to link with shared libav* because the number of...
int16_t * vLumFilter
Array of vertical filter coefficients for luma/alpha planes.
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
planar GBR 4:4:4 48bpp, little-endian
int16_t * hChrFilter
Array of horizontal filter coefficients for chroma planes.
packed BGR 4:4:4, 16bpp, (msb)4A 4B 4G 4R(lsb), little-endian, most significant bits to 1 ...
planar YUV 4:2:2 27bpp, (1 Cr & Cb sample per 2x1 Y & A samples), little-endian
int sws_isSupportedInput(enum AVPixelFormat pix_fmt)
Return a positive value if pix_fmt is a supported input format, 0 otherwise.
int chrDstHSubSample
Binary logarithm of horizontal subsampling factor between luma/alpha and chroma planes in destination...
int chrSrcW
Width of source chroma planes.
void ff_get_unscaled_swscale(SwsContext *c)
Set c->swScale to an unscaled converter if one exists for the specific source and destination formats...
int srcW
Width of source luma/alpha planes.
packed YUV 4:1:1, 12bpp, Cb Y0 Y1 Cr Y2 Y3
int chrSrcVSubSample
Binary logarithm of vertical subsampling factor between luma/alpha and chroma planes in source image...
int flags
Flags passed by the user to select scaler algorithm, optimizations, subsampling, etc...
AVPixelFormat
Pixel format.
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
void sws_addVec(SwsVector *a, SwsVector *b)
planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
#define FF_ALLOCZ_OR_GOTO(ctx, p, size, label)
planar GBR 4:4:4 30bpp, little-endian
const int32_t ff_yuv2rgb_coeffs[8][4]
static SwsVector * sws_getConvVec(SwsVector *a, SwsVector *b)
#define LIBSWSCALE_VERSION_INT
planar YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian