23 #define _DEFAULT_SOURCE
25 #define _DARWIN_C_SOURCE
32 #if defined(MAP_ANON) && !defined(MAP_ANONYMOUS)
33 #define MAP_ANONYMOUS MAP_ANON
37 #define WIN32_LEAN_AND_MEAN
60 #undef attribute_deprecated
61 #define attribute_deprecated
67 #if !FF_API_SWS_VECTOR
89 #define LICENSE_PREFIX "libswscale license: "
300 return ((d * dist +
c) * dist +
b) * dist +
a;
303 b + 2.0 *
c + 3.0 * d,
305 -
b - 3.0 *
c - 6.0 * d,
311 if (
pos == -1 ||
pos <= -513) {
312 pos = (128 << chr_subsample) - 128;
315 return pos >> chr_subsample;
332 {
SWS_POINT,
"nearest neighbor / point", -1 },
335 {
SWS_X,
"experimental", 8 },
339 int *outFilterSize,
int xInc,
int srcW,
340 int dstW,
int filterAlign,
int one,
343 double param[2],
int srcPos,
int dstPos)
360 if (
FFABS(xInc - 0x10000) < 10 && srcPos == dstPos) {
366 for (
i = 0;
i < dstW;
i++) {
377 xDstInSrc = ((dstPos*(
int64_t)xInc)>>8) - ((srcPos*0x8000LL)>>7);
378 for (
i = 0;
i < dstW;
i++) {
379 int xx = (xDstInSrc - ((filterSize - 1) << 15) + (1 << 15)) >> 16;
381 (*filterPos)[
i] = xx;
393 xDstInSrc = ((dstPos*(
int64_t)xInc)>>8) - ((srcPos*0x8000LL)>>7);
394 for (
i = 0;
i < dstW;
i++) {
395 int xx = (xDstInSrc - ((filterSize - 1) << 15) + (1 << 15)) >> 16;
398 (*filterPos)[
i] = xx;
400 for (j = 0; j < filterSize; j++) {
423 if (sizeFactor > 50) {
429 filterSize = 1 + sizeFactor;
431 filterSize = 1 + (sizeFactor * srcW + dstW - 1) / dstW;
433 filterSize =
FFMIN(filterSize, srcW - 2);
434 filterSize =
FFMAX(filterSize, 1);
439 xDstInSrc = ((dstPos*(
int64_t)xInc)>>7) - ((srcPos*0x10000LL)>>7);
440 for (
i = 0;
i < dstW;
i++) {
441 int xx = (xDstInSrc - (filterSize - 2) * (1LL<<16)) / (1 << 17);
443 (*filterPos)[
i] = xx;
444 for (j = 0; j < filterSize; j++) {
451 floatd = d * (1.0 / (1 << 30));
457 if (d >= 1LL << 31) {
464 coeff = (12 * (1 << 24) - 9 *
B - 6 *
C) * ddd +
465 (-18 * (1 << 24) + 12 *
B + 6 *
C) * dd +
466 (6 * (1 << 24) - 2 *
B) * (1 << 30);
469 (6 *
B + 30 *
C) * dd +
470 (-12 *
B - 48 *
C) * d +
471 (8 *
B + 24 *
C) * (1 << 30);
473 coeff /= (1LL<<54)/fone;
479 c = cos(floatd *
M_PI);
486 coeff = (
c * 0.5 + 0.5) * fone;
489 if (d2 * xInc < -(1LL << (29 + 16)))
490 coeff = 1.0 * (1LL << (30 + 16));
491 else if (d2 * xInc < (1LL << (29 + 16)))
492 coeff = -d2 * xInc + (1LL << (29 + 16));
495 coeff *= fone >> (30 + 16);
498 coeff =
exp2(-p * floatd * floatd) * fone;
500 coeff = (d ? sin(floatd *
M_PI) / (floatd *
M_PI) : 1.0) * fone;
504 (floatd * floatd *
M_PI *
M_PI / p) : 1.0) * fone;
508 coeff = (1 << 30) - d;
513 double p = -2.196152422706632;
522 xDstInSrc += 2LL * xInc;
530 filter2Size = filterSize;
532 filter2Size += srcFilter->
length - 1;
534 filter2Size += dstFilter->
length - 1;
536 filter2 =
av_calloc(dstW, filter2Size *
sizeof(*filter2));
539 for (
i = 0;
i < dstW;
i++) {
543 for (k = 0; k < srcFilter->
length; k++) {
544 for (j = 0; j < filterSize; j++)
545 filter2[
i * filter2Size + k + j] +=
549 for (j = 0; j < filterSize; j++)
550 filter2[
i * filter2Size + j] =
filter[
i * filterSize + j];
554 (*filterPos)[
i] += (filterSize - 1) / 2 - (filter2Size - 1) / 2;
561 for (
i = dstW - 1;
i >= 0;
i--) {
562 int min = filter2Size;
567 for (j = 0; j < filter2Size; j++) {
569 cutOff +=
FFABS(filter2[
i * filter2Size]);
576 if (
i < dstW - 1 && (*filterPos)[
i] >= (*filterPos)[
i + 1])
580 for (k = 1; k < filter2Size; k++)
581 filter2[
i * filter2Size + k - 1] = filter2[
i * filter2Size + k];
582 filter2[
i * filter2Size + k - 1] = 0;
588 for (j = filter2Size - 1; j > 0; j--) {
589 cutOff +=
FFABS(filter2[
i * filter2Size + j]);
596 if (
min > minFilterSize)
602 if (minFilterSize < 5)
608 if (minFilterSize < 3)
614 if (minFilterSize == 1 && filterAlign == 2)
619 filterSize = (minFilterSize + (filterAlign - 1)) & (~(filterAlign - 1));
632 "SwScaler: reducing / aligning filtersize %d -> %d\n",
633 filter2Size, filterSize);
635 for (
i = 0;
i < dstW;
i++) {
638 for (j = 0; j < filterSize; j++) {
639 if (j >= filter2Size)
640 filter[
i * filterSize + j] = 0;
642 filter[
i * filterSize + j] = filter2[
i * filter2Size + j];
644 filter[
i * filterSize + j] = 0;
651 for (
i = 0;
i < dstW;
i++) {
653 if ((*filterPos)[
i] < 0) {
655 for (j = 1; j < filterSize; j++) {
656 int left =
FFMAX(j + (*filterPos)[
i], 0);
658 filter[
i * filterSize + j] = 0;
663 if ((*filterPos)[
i] + filterSize > srcW) {
664 int shift = (*filterPos)[
i] +
FFMIN(filterSize - srcW, 0);
667 for (j = filterSize - 1; j >= 0; j--) {
668 if ((*filterPos)[
i] + j >= srcW) {
670 filter[
i * filterSize + j] = 0;
673 for (j = filterSize - 1; j >= 0; j--) {
675 filter[
i * filterSize + j] = 0;
682 filter[
i * filterSize + srcW - 1 - (*filterPos)[
i]] +=
acc;
686 if ((*filterPos)[
i] + filterSize > srcW) {
687 for (j = 0; j < filterSize; j++) {
693 *outFilterSize =
FFMIN(filterSize,
FFALIGN(srcW, filterAlign));
697 *outFilter =
av_calloc(dstW + 3, *outFilterSize *
sizeof(**outFilter));
702 for (
i = 0;
i < dstW;
i++) {
707 for (j = 0; j < filterSize; j++) {
708 sum +=
filter[
i * filterSize + j];
710 sum = (sum + one / 2) / one;
715 for (j = 0; j < *outFilterSize; j++) {
718 (*outFilter)[
i * (*outFilterSize) + j] = intV;
719 error = v - intV * sum;
723 (*filterPos)[dstW + 0] =
724 (*filterPos)[dstW + 1] =
725 (*filterPos)[dstW + 2] = (*filterPos)[dstW - 1];
727 for (
i = 0;
i < *outFilterSize;
i++) {
728 int k = (dstW - 1) * (*outFilterSize) +
i;
729 (*outFilter)[k + 1 * (*outFilterSize)] =
730 (*outFilter)[k + 2 * (*outFilterSize)] =
731 (*outFilter)[k + 3 * (*outFilterSize)] = (*outFilter)[k];
758 static const int8_t
map[] = {
783 -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 ,
784 -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 ,
785 -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 ,
786 -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 ,
787 -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 ,
788 -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 ,
789 -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 ,
790 -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 ,
848 static const int16_t xyz2rgb_matrix[3][4] = {
849 {13270, -6295, -2041},
851 { 228, -835, 4329} };
852 static const int16_t rgb2xyz_matrix[3][4] = {
856 static int16_t xyzgamma_tab[4096], rgbgamma_tab[4096], xyzgammainv_tab[4096], rgbgammainv_tab[4096];
858 memcpy(
c->xyz2rgb_matrix, xyz2rgb_matrix,
sizeof(
c->xyz2rgb_matrix));
859 memcpy(
c->rgb2xyz_matrix, rgb2xyz_matrix,
sizeof(
c->rgb2xyz_matrix));
860 c->xyzgamma = xyzgamma_tab;
861 c->rgbgamma = rgbgamma_tab;
862 c->xyzgammainv = xyzgammainv_tab;
863 c->rgbgammainv = rgbgammainv_tab;
865 if (rgbgamma_tab[4095])
869 for (
i = 0;
i < 4096;
i++) {
870 xyzgamma_tab[
i] =
lrint(pow(
i / 4095.0, xyzgamma) * 4095.0);
871 rgbgamma_tab[
i] =
lrint(pow(
i / 4095.0, rgbgamma) * 4095.0);
872 xyzgammainv_tab[
i] =
lrint(pow(
i / 4095.0, xyzgammainv) * 4095.0);
873 rgbgammainv_tab[
i] =
lrint(pow(
i / 4095.0, rgbgammainv) * 4095.0);
883 int srcRange,
const int table[4],
int dstRange,
884 int brightness,
int contrast,
int saturation)
899 if (
c->srcRange != srcRange ||
900 c->dstRange != dstRange ||
901 c->brightness != brightness ||
902 c->contrast != contrast ||
903 c->saturation != saturation ||
904 memcmp(
c->srcColorspaceTable, inv_table,
sizeof(
int) * 4) ||
905 memcmp(
c->dstColorspaceTable,
table,
sizeof(
int) * 4)
909 memmove(
c->srcColorspaceTable, inv_table,
sizeof(
int) * 4);
910 memmove(
c->dstColorspaceTable,
table,
sizeof(
int) * 4);
914 c->brightness = brightness;
915 c->contrast = contrast;
916 c->saturation = saturation;
917 c->srcRange = srcRange;
918 c->dstRange = dstRange;
922 if (need_reinit && (
c->srcBpc == 8 || !
isYUV(
c->srcFormat)))
928 if (
c->cascaded_context[
c->cascaded_mainindex])
935 if (!
c->cascaded_context[0] &&
936 memcmp(
c->dstColorspaceTable,
c->srcColorspaceTable,
sizeof(
int) * 4) &&
937 c->srcW &&
c->srcH &&
c->dstW &&
c->dstH) {
939 int tmp_width, tmp_height;
945 av_log(
c,
AV_LOG_VERBOSE,
"YUV color matrix differs for YUV->YUV, using intermediate RGB to convert\n");
961 if (srcW*srcH > dstW*dstH) {
970 tmp_width, tmp_height, tmp_format, 64);
975 tmp_width, tmp_height, tmp_format,
977 if (!
c->cascaded_context[0])
980 c->cascaded_context[0]->alphablend =
c->alphablend;
986 srcRange,
table, dstRange,
987 brightness, contrast, saturation);
989 c->cascaded_context[1] =
sws_getContext(tmp_width, tmp_height, tmp_format,
990 dstW, dstH,
c->dstFormat,
992 if (!
c->cascaded_context[1])
995 srcRange,
table, dstRange,
996 0, 1 << 16, 1 << 16);
1004 contrast, saturation);
1009 contrast, saturation);
1018 int *srcRange,
int **
table,
int *dstRange,
1019 int *brightness,
int *contrast,
int *saturation)
1024 *inv_table =
c->srcColorspaceTable;
1025 *
table =
c->dstColorspaceTable;
1028 *brightness =
c->brightness;
1029 *contrast =
c->contrast;
1030 *saturation =
c->saturation;
1099 if (
c->srcXYZ ||
c->dstXYZ)
1121 tbl = (uint16_t*)
av_malloc(
sizeof(uint16_t) * 1 << 16);
1125 for (
i = 0;
i < 65536; ++
i) {
1126 tbl[
i] = pow(
i / 65535.0, e) * 65535.0;
1193 int usesVFilter, usesHFilter;
1200 int dst_stride =
FFALIGN(dstW *
sizeof(int16_t) + 66, 16);
1208 static const float float_mult = 1.0f / 255.0f;
1217 unscaled = (srcW == dstW && srcH == dstH);
1222 if(srcFormat!=
c->srcFormat || dstFormat!=
c->dstFormat)
1225 if (!
c->contrast && !
c->saturation && !
c->dstFormatBpp)
1228 c->dstRange, 0, 1 << 16, 1 << 16);
1231 srcFormat =
c->srcFormat;
1232 dstFormat =
c->dstFormat;
1269 if (dstW < srcW && dstH < srcH)
1271 else if (dstW > srcW && dstH > srcH)
1276 }
else if (
i & (
i - 1)) {
1278 "Exactly one scaler algorithm must be chosen, got %X\n",
i);
1282 if (srcW < 1 || srcH < 1 || dstW < 1 || dstH < 1) {
1286 srcW, srcH, dstW, dstH);
1291 if (srcW < 8 || dstW <= 8 || srcW >= 65536) {
1304 dstFilter = &dummyFilter;
1306 srcFilter = &dummyFilter;
1312 c->vRounder = 4 * 0x0001000100010001ULL;
1314 usesVFilter = (srcFilter->
lumV && srcFilter->
lumV->
length > 1) ||
1318 usesHFilter = (srcFilter->
lumH && srcFilter->
lumH->
length > 1) ||
1333 if (
c->chrSrcHSubSample == 0
1334 &&
c->chrSrcVSubSample == 0
1338 av_log(
c,
AV_LOG_DEBUG,
"Forcing full internal H chroma due to input having non subsampled chroma\n");
1358 "Desired dithering only supported in full chroma interpolation for destination format '%s'\n",
1367 "Ordered dither is not supported in full chroma interpolation for destination format '%s'\n",
1376 "%s output is not supported with half chroma resolution, switching to full\n",
1408 "full chroma interpolation for destination format '%s' not yet implemented\n",
1414 c->chrDstHSubSample = 1;
1419 c->chrSrcVSubSample +=
c->vChrDrop;
1437 ((dstW >>
c->chrDstHSubSample) <= (srcW >> 1) ||
1439 c->chrSrcHSubSample = 1;
1458 if (
c->dstBpc == 16)
1462 c->canMMXEXTBeUsed = dstW >= srcW && (dstW & 31) == 0 &&
1463 c->chrDstW >=
c->chrSrcW &&
1465 if (!
c->canMMXEXTBeUsed && dstW >= srcW &&
c->chrDstW >=
c->chrSrcW && (srcW & 15) == 0
1470 "output width is not a multiple of 32 -> no MMXEXT scaler\n");
1473 c->canMMXEXTBeUsed = 0;
1475 c->canMMXEXTBeUsed = 0;
1477 int64_t chrXInc = (((
int64_t)
c->chrSrcW << 16) + (
c->chrDstW >> 1)) /
c->chrDstW;
1478 int64_t chrYInc = (((
int64_t)
c->chrSrcH << 16) + (
c->chrDstH >> 1)) /
c->chrDstH;
1488 if (
c->canMMXEXTBeUsed) {
1494 lumXInc = ((
int64_t)(srcW - 2) << 16) / (dstW - 2) - 20;
1495 chrXInc = ((
int64_t)(
c->chrSrcW - 2) << 16) / (
c->chrDstW - 2) - 20;
1498 if (chrXInc < 10 || chrXInc > INT_MAX ||
1499 chrYInc < 10 || chrYInc > INT_MAX ||
1500 lumXInc < 10 || lumXInc > INT_MAX ||
1501 lumYInc < 10 || lumYInc > INT_MAX)
1504 c->lumXInc = lumXInc;
1505 c->lumYInc = lumYInc;
1506 c->chrXInc = chrXInc;
1507 c->chrYInc = chrYInc;
1511 c->gamma_value = 2.2;
1515 if (!unscaled &&
c->gamma_flag && (srcFormat != tmpFmt || dstFormat != tmpFmt)) {
1517 c->cascaded_context[0] =
NULL;
1520 srcW, srcH, tmpFmt, 64);
1527 if (!
c->cascaded_context[0]) {
1533 flags, srcFilter, dstFilter,
c->param);
1535 if (!
c->cascaded_context[1])
1538 c2 =
c->cascaded_context[1];
1539 c2->is_internal_gamma = 1;
1542 if (!
c2->gamma || !
c2->inv_gamma)
1551 c->cascaded_context[1] =
NULL;
1555 c->cascaded_context[2] =
NULL;
1556 if (dstFormat != tmpFmt) {
1558 dstW, dstH, tmpFmt, 64);
1563 dstW, dstH, dstFormat,
1565 if (!
c->cascaded_context[2])
1578 srcW, srcH, tmpFormat, 64);
1583 srcW, srcH, tmpFormat,
1585 if (!
c->cascaded_context[0])
1589 dstW, dstH, dstFormat,
1591 if (!
c->cascaded_context[1])
1598 for (
i = 0;
i < 256; ++
i){
1599 c->uint2float_lut[
i] = (float)
i * float_mult;
1605 (!unscaled || unscaled && dstFormat != srcFormat && (srcFormat !=
AV_PIX_FMT_GRAYF32 ||
1615 dstFormat != tmpFormat ||
1616 usesHFilter || usesVFilter ||
1617 c->srcRange !=
c->dstRange
1619 c->cascaded_mainindex = 1;
1621 srcW, srcH, tmpFormat, 64);
1626 srcW, srcH, tmpFormat,
1628 if (!
c->cascaded_context[0])
1630 c->cascaded_context[0]->alphablend =
c->alphablend;
1636 dstW, dstH, dstFormat,
1638 if (!
c->cascaded_context[1])
1641 c->cascaded_context[1]->srcRange =
c->srcRange;
1642 c->cascaded_context[1]->dstRange =
c->dstRange;
1652 #if HAVE_MMAP && HAVE_MPROTECT && defined(MAP_ANONYMOUS)
1660 #if HAVE_MMXEXT_INLINE
1669 c->lumMmxextFilterCode = mmap(
NULL,
c->lumMmxextFilterCodeSize,
1670 PROT_READ | PROT_WRITE,
1671 MAP_PRIVATE | MAP_ANONYMOUS,
1673 c->chrMmxextFilterCode = mmap(
NULL,
c->chrMmxextFilterCodeSize,
1674 PROT_READ | PROT_WRITE,
1675 MAP_PRIVATE | MAP_ANONYMOUS,
1677 #elif HAVE_VIRTUALALLOC
1678 c->lumMmxextFilterCode = VirtualAlloc(
NULL,
1679 c->lumMmxextFilterCodeSize,
1681 PAGE_EXECUTE_READWRITE);
1682 c->chrMmxextFilterCode = VirtualAlloc(
NULL,
1683 c->chrMmxextFilterCodeSize,
1685 PAGE_EXECUTE_READWRITE);
1687 c->lumMmxextFilterCode =
av_malloc(
c->lumMmxextFilterCodeSize);
1688 c->chrMmxextFilterCode =
av_malloc(
c->chrMmxextFilterCodeSize);
1691 #ifdef MAP_ANONYMOUS
1692 if (
c->lumMmxextFilterCode == MAP_FAILED ||
c->chrMmxextFilterCode == MAP_FAILED)
1694 if (!
c->lumMmxextFilterCode || !
c->chrMmxextFilterCode)
1708 c->hLumFilter, (uint32_t*)
c->hLumFilterPos, 8);
1710 c->hChrFilter, (uint32_t*)
c->hChrFilterPos, 4);
1713 if ( mprotect(
c->lumMmxextFilterCode,
c->lumMmxextFilterCodeSize, PROT_EXEC | PROT_READ) == -1
1714 || mprotect(
c->chrMmxextFilterCode,
c->chrMmxextFilterCodeSize, PROT_EXEC | PROT_READ) == -1) {
1727 if ((ret =
initFilter(&
c->hLumFilter, &
c->hLumFilterPos,
1728 &
c->hLumFilterSize,
c->lumXInc,
1729 srcW, dstW, filterAlign, 1 << 14,
1736 if ((ret =
initFilter(&
c->hChrFilter, &
c->hChrFilterPos,
1737 &
c->hChrFilterSize,
c->chrXInc,
1738 c->chrSrcW,
c->chrDstW, filterAlign, 1 << 14,
1754 ret =
initFilter(&
c->vLumFilter, &
c->vLumFilterPos, &
c->vLumFilterSize,
1755 c->lumYInc, srcH, dstH, filterAlign, (1 << 12),
1762 if (ret < 0 && !usecascade)
1764 if ((ret =
initFilter(&
c->vChrFilter, &
c->vChrFilterPos, &
c->vChrFilterSize,
1765 c->chrYInc,
c->chrSrcH,
c->chrDstH,
1766 filterAlign, (1 << 12),
1781 c->vCCoeffsBank =
av_malloc_array(
c->chrDstH,
c->vChrFilterSize *
sizeof(*
c->vCCoeffsBank));
1782 if (
c->vYCoeffsBank ==
NULL ||
c->vCCoeffsBank ==
NULL)
1785 for (
i = 0;
i <
c->vLumFilterSize *
c->dstH;
i++) {
1787 short *p = (
short *)&
c->vYCoeffsBank[
i];
1788 for (j = 0; j < 8; j++)
1789 p[j] =
c->vLumFilter[
i];
1792 for (
i = 0;
i <
c->vChrFilterSize *
c->chrDstH;
i++) {
1794 short *p = (
short *)&
c->vCCoeffsBank[
i];
1795 for (j = 0; j < 8; j++)
1796 p[j] =
c->vChrFilter[
i];
1801 for (
i = 0;
i < 4;
i++)
1808 c->uv_off = (dst_stride>>1) + 64 / (
c->dstBpc &~ 7);
1809 c->uv_offx2 = dst_stride + 16;
1814 const char *scaler =
NULL, *cpucaps;
1823 scaler =
"ehh flags invalid?!";
1844 cpucaps =
"AltiVec";
1852 "lum srcW=%d srcH=%d dstW=%d dstH=%d xInc=%d yInc=%d\n",
1853 c->srcW,
c->srcH,
c->dstW,
c->dstH,
c->lumXInc,
c->lumYInc);
1855 "chr srcW=%d srcH=%d dstW=%d dstH=%d xInc=%d yInc=%d\n",
1856 c->chrSrcW,
c->chrSrcH,
c->chrDstW,
c->chrDstH,
1857 c->chrXInc,
c->chrYInc);
1861 if (unscaled && !usesHFilter && !usesVFilter &&
1864 (
c->srcRange ==
c->dstRange ||
isAnyRGB(dstFormat)) &&
1871 "using alpha blendaway %s -> %s special converter\n",
1877 if (unscaled && !usesHFilter && !usesVFilter &&
1878 (
c->srcRange ==
c->dstRange ||
isAnyRGB(dstFormat) ||
1885 "using unscaled %s -> %s special converter\n",
1897 int tmpW = sqrt(srcW * (
int64_t)dstW);
1898 int tmpH = sqrt(srcH * (
int64_t)dstH);
1904 if (srcW*(
int64_t)srcH <= 4LL*dstW*dstH)
1908 tmpW, tmpH, tmpFormat, 64);
1913 tmpW, tmpH, tmpFormat,
1915 if (!
c->cascaded_context[0])
1919 dstW, dstH, dstFormat,
1921 if (!
c->cascaded_context[1])
1930 int flags,
const double *param)
1942 c->srcFormat = srcFormat;
1943 c->dstFormat = dstFormat;
1946 c->param[0] = param[0];
1947 c->param[1] = param[1];
1956 SwsFilter *dstFilter,
const double *param)
1961 dstW, dstH, dstFormat,
1977 for (
i=0;
i<
a->length;
i++)
1986 for (
i=0;
i<
a->length;
i++)
1991 float lumaSharpen,
float chromaSharpen,
1992 float chromaHShift,
float chromaVShift,
1999 if (lumaGBlur != 0.0) {
2007 if (chromaGBlur != 0.0) {
2018 if (chromaSharpen != 0.0) {
2029 if (lumaSharpen != 0.0) {
2040 if (chromaHShift != 0.0)
2043 if (chromaVShift != 0.0)
2077 if(length <= 0 || length > INT_MAX/
sizeof(
double))
2092 const int length = (
int)(variance * quality + 0.5) | 1;
2094 double middle = (length - 1) * 0.5;
2097 if(variance < 0 || quality < 0)
2105 for (
i = 0;
i < length;
i++) {
2106 double dist =
i - middle;
2107 vec->
coeff[
i] =
exp(-dist * dist / (2 * variance * variance)) /
2108 sqrt(2 * variance *
M_PI);
2120 #if !FF_API_SWS_VECTOR
2131 for (
i = 0;
i < length;
i++)
2141 #if !FF_API_SWS_VECTOR
2154 for (
i = 0;
i <
a->length;
i++)
2164 for (
i = 0;
i <
a->length;
i++)
2165 a->coeff[
i] *= scalar;
2173 #if FF_API_SWS_VECTOR
2176 int length =
a->length +
b->length - 1;
2183 for (
i = 0;
i <
a->length;
i++) {
2184 for (j = 0; j <
b->length; j++) {
2185 vec->
coeff[
i + j] +=
a->coeff[
i] *
b->coeff[j];
2195 int length =
FFMAX(
a->length,
b->length);
2202 for (
i = 0;
i <
a->length;
i++)
2203 vec->
coeff[
i + (length - 1) / 2 - (
a->length - 1) / 2] +=
a->coeff[
i];
2204 for (
i = 0;
i <
b->length;
i++)
2205 vec->
coeff[
i + (length - 1) / 2 - (
b->length - 1) / 2] +=
b->coeff[
i];
2210 #if FF_API_SWS_VECTOR
2213 int length =
FFMAX(
a->length,
b->length);
2220 for (
i = 0;
i <
a->length;
i++)
2221 vec->
coeff[
i + (length - 1) / 2 - (
a->length - 1) / 2] +=
a->coeff[
i];
2222 for (
i = 0;
i <
b->length;
i++)
2223 vec->
coeff[
i + (length - 1) / 2 - (
b->length - 1) / 2] -=
b->coeff[
i];
2239 for (
i = 0;
i <
a->length;
i++) {
2240 vec->
coeff[
i + (length - 1) / 2 -
2241 (
a->length - 1) / 2 -
shift] =
a->coeff[
i];
2247 #if !FF_API_SWS_VECTOR
2258 a->coeff = shifted->
coeff;
2263 #if !FF_API_SWS_VECTOR
2279 #if FF_API_SWS_VECTOR
2288 a->coeff =
diff->coeff;
2289 a->length =
diff->length;
2301 a->coeff =
conv->coeff;
2302 a->length =
conv->length;
2313 memcpy(vec->
coeff,
a->coeff,
a->length *
sizeof(*
a->coeff));
2323 #if !FF_API_SWS_VECTOR
2333 for (
i = 0;
i <
a->length;
i++)
2334 if (
a->coeff[
i] >
max)
2337 for (
i = 0;
i <
a->length;
i++)
2338 if (
a->coeff[
i] <
min)
2343 for (
i = 0;
i <
a->length;
i++) {
2344 int x = (
int)((
a->coeff[
i] -
min) * 60.0 / range + 0.5);
2345 av_log(log_ctx, log_level,
"%1.3f ",
a->coeff[
i]);
2347 av_log(log_ctx, log_level,
" ");
2348 av_log(log_ctx, log_level,
"|\n");
2379 for (
i = 0;
i < 4;
i++)
2398 if (
c->lumMmxextFilterCode)
2399 munmap(
c->lumMmxextFilterCode,
c->lumMmxextFilterCodeSize);
2400 if (
c->chrMmxextFilterCode)
2401 munmap(
c->chrMmxextFilterCode,
c->chrMmxextFilterCodeSize);
2402 #elif HAVE_VIRTUALALLOC
2403 if (
c->lumMmxextFilterCode)
2404 VirtualFree(
c->lumMmxextFilterCode, 0, MEM_RELEASE);
2405 if (
c->chrMmxextFilterCode)
2406 VirtualFree(
c->chrMmxextFilterCode, 0, MEM_RELEASE);
2411 c->lumMmxextFilterCode =
NULL;
2412 c->chrMmxextFilterCode =
NULL;
2421 memset(
c->cascaded_context, 0,
sizeof(
c->cascaded_context));
2439 const double *
param)
2447 param = default_param;
static const char *const format[]
int ff_sws_alphablendaway(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dst[], int dstStride[])
Macro definitions for various function/variable attributes.
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert2(cond)
assert() equivalent, that does lie in speed critical code.
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Convenience header that includes libavutil's core.
#define flags(name, subs,...)
static av_always_inline void filter(int16_t *output, ptrdiff_t out_stride, const int16_t *low, ptrdiff_t low_stride, const int16_t *high, ptrdiff_t high_stride, int len, int clip)
#define AV_CEIL_RSHIFT(a, b)
#define ROUNDED_DIV(a, b)
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
#define FFMPEG_CONFIGURATION
#define CONFIG_SWSCALE_ALPHA
static atomic_int cpu_flags
int av_get_cpu_flags(void)
Return the flags which specify extensions supported by the CPU.
#define AV_CPU_FLAG_MMX
standard MMX
static __device__ float ceil(float a)
static enum AVPixelFormat pix_fmt
void av_opt_set_defaults(void *s)
Set the values of all AVOption fields to their default values.
#define AVERROR_UNKNOWN
Unknown error, typically from an external library.
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_LOG_VERBOSE
Detailed information.
#define AV_LOG_INFO
Standard information.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
void * av_calloc(size_t nmemb, size_t size)
Non-inlined equivalent of av_mallocz_array().
int av_image_alloc(uint8_t *pointers[4], int linesizes[4], int w, int h, enum AVPixelFormat pix_fmt, int align)
Allocate an image with size w and h and pixel format pix_fmt, and fill pointers and linesizes accordi...
int av_image_check_size2(unsigned int w, unsigned int h, int64_t max_pixels, enum AVPixelFormat pix_fmt, int log_offset, void *log_ctx)
Check if the given dimension of an image is valid, meaning that all bytes of a plane of an image with...
void sws_subVec(SwsVector *a, SwsVector *b)
int sws_getColorspaceDetails(struct SwsContext *c, int **inv_table, int *srcRange, int **table, int *dstRange, int *brightness, int *contrast, int *saturation)
void sws_freeFilter(SwsFilter *filter)
void sws_addVec(SwsVector *a, SwsVector *b)
av_cold int sws_init_context(SwsContext *c, SwsFilter *srcFilter, SwsFilter *dstFilter)
Initialize the swscaler context sws_context.
SwsVector * sws_getGaussianVec(double variance, double quality)
Return a normalized Gaussian curve used to filter stuff quality = 3 is high quality,...
void sws_shiftVec(SwsVector *a, int shift)
#define SWS_SRC_V_CHR_DROP_MASK
#define SWS_FULL_CHR_H_INT
#define SWS_FULL_CHR_H_INP
SwsVector * sws_getConstVec(double c, int length)
Allocate and return a vector with length coefficients, all with the same value c.
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)
void sws_freeVec(SwsVector *a)
SwsVector * sws_cloneVec(SwsVector *a)
#define SWS_FAST_BILINEAR
int sws_isSupportedEndiannessConversion(enum AVPixelFormat pix_fmt)
int sws_isSupportedOutput(enum AVPixelFormat pix_fmt)
Return a positive value if pix_fmt is a supported output format, 0 otherwise.
#define SWS_SRC_V_CHR_DROP_SHIFT
SwsVector * sws_allocVec(int length)
Allocate and return an uninitialized vector with length coefficients.
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.
#define SWS_ERROR_DIFFUSION
void sws_convVec(SwsVector *a, SwsVector *b)
SwsVector * sws_getIdentityVec(void)
Allocate and return a vector with just one coefficient, with value 1.0.
const char * swscale_license(void)
Return the libswscale license.
const char * swscale_configuration(void)
Return the libswscale build-time configuration.
void sws_normalizeVec(SwsVector *a, double height)
Scale all the coefficients of a so that their sum equals height.
int sws_isSupportedInput(enum AVPixelFormat pix_fmt)
Return a positive value if pix_fmt is a supported input format, 0 otherwise.
SwsFilter * sws_getDefaultFilter(float lumaGBlur, float chromaGBlur, float lumaSharpen, float chromaSharpen, float chromaHShift, float chromaVShift, int verbose)
SwsContext * sws_alloc_context(void)
Allocate an empty SwsContext.
unsigned swscale_version(void)
#define SWS_MAX_REDUCE_CUTOFF
void sws_freeContext(SwsContext *c)
Free the swscaler context swsContext.
#define SWS_PARAM_DEFAULT
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.
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.
void sws_scaleVec(SwsVector *a, double scalar)
Scale all the coefficients of a by the scalar value.
int av_opt_get_int(void *obj, const char *name, int search_flags, int64_t *out_val)
int av_opt_set_int(void *obj, const char *name, int64_t val, int search_flags)
const VDPAUPixFmtMap * map
#define FF_ALLOC_TYPED_ARRAY(p, nelem)
#define FF_ALLOCZ_TYPED_ARRAY(p, nelem)
static int ff_thread_once(char *control, void(*routine)(void))
Replacements for frequently missing libm functions.
const AVClass ff_sws_context_class
static int handle_0alpha(enum AVPixelFormat *format)
static int handle_xyz(enum AVPixelFormat *format)
static void fill_xyztables(struct SwsContext *c)
static enum AVPixelFormat alphaless_fmt(enum AVPixelFormat fmt)
SwsContext * sws_alloc_set_opts(int srcW, int srcH, enum AVPixelFormat srcFormat, int dstW, int dstH, enum AVPixelFormat dstFormat, int flags, const double *param)
Allocate and return an SwsContext.
static av_cold 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 srcPos, int dstPos)
static int handle_jpeg(enum AVPixelFormat *format)
static const ScaleAlgorithm scale_algorithms[]
static double getSplineCoeff(double a, double b, double c, double d, double dist)
static void fill_rgb2yuv_table(SwsContext *c, const int table[4], int dstRange)
static SwsVector * sws_getConvVec(SwsVector *a, SwsVector *b)
static SwsVector * sws_sumVec(SwsVector *a, SwsVector *b)
static av_cold int get_local_pos(SwsContext *s, int chr_subsample, int pos, int dir)
static void makenan_vec(SwsVector *a)
static void handle_formats(SwsContext *c)
static double sws_dcVec(SwsVector *a)
static int isnan_vec(SwsVector *a)
static uint16_t * alloc_gamma_tbl(double e)
static const FormatEntry format_entries[]
static SwsVector * sws_getShiftedVec(SwsVector *a, int shift)
static SwsVector * sws_diffVec(SwsVector *a, SwsVector *b)
static int range_override_needed(enum AVPixelFormat format)
#define LIBSWSCALE_VERSION_INT
#define LIBSWSCALE_VERSION_MICRO
static int conv(int samples, float **pcm, char *buf, int channels)
int av_pix_fmt_get_chroma_sub_sample(enum AVPixelFormat pix_fmt, int *h_shift, int *v_shift)
Utility function to access log2_chroma_w log2_chroma_h from the pixel format AVPixFmtDescriptor.
int av_get_bits_per_pixel(const AVPixFmtDescriptor *pixdesc)
Return the number of bits per pixel used by the pixel format described by pixdesc.
const char * av_get_pix_fmt_name(enum AVPixelFormat pix_fmt)
Return the short name for a pixel format, NULL in case pix_fmt is unknown.
enum AVPixelFormat av_pix_fmt_swap_endianness(enum AVPixelFormat pix_fmt)
Utility function to swap the endianness of a pixel format.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
#define AV_PIX_FMT_YUV420P16
#define AV_PIX_FMT_YUV444P9
#define AV_PIX_FMT_YUV420P10
#define AV_PIX_FMT_YUV422P9
#define AV_PIX_FMT_BGR555
#define AV_PIX_FMT_GBRP10
#define AV_PIX_FMT_YUV422P10
#define AV_PIX_FMT_GBRP12
#define AV_PIX_FMT_YUV420P9
#define AV_PIX_FMT_GRAYF32
AVPixelFormat
Pixel format.
@ AV_PIX_FMT_BAYER_GBRG8
bayer, GBGB..(odd line), RGRG..(even line), 8-bit samples
@ AV_PIX_FMT_YUV444P16BE
planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
@ AV_PIX_FMT_GRAY16BE
Y , 16bpp, big-endian.
@ AV_PIX_FMT_XYZ12LE
packed XYZ 4:4:4, 36 bpp, (msb) 12X, 12Y, 12Z (lsb), the 2-byte value for each X/Y/Z is stored as lit...
@ AV_PIX_FMT_NV12
planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (firs...
@ AV_PIX_FMT_YUV420P16BE
planar YUV 4:2:0, 24bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
@ AV_PIX_FMT_P010LE
like NV12, with 10bpp per component, data in the high bits, zeros in the low bits,...
@ AV_PIX_FMT_RGB24
packed RGB 8:8:8, 24bpp, RGBRGB...
@ AV_PIX_FMT_GRAY10LE
Y , 10bpp, little-endian.
@ AV_PIX_FMT_GRAYF32LE
IEEE-754 single precision Y, 32bpp, little-endian.
@ AV_PIX_FMT_GBRP10BE
planar GBR 4:4:4 30bpp, big-endian
@ AV_PIX_FMT_YA16BE
16 bits gray, 16 bits alpha (big-endian)
@ AV_PIX_FMT_YUVA420P9BE
planar YUV 4:2:0 22.5bpp, (1 Cr & Cb sample per 2x2 Y & A samples), big-endian
@ AV_PIX_FMT_YUVA444P12BE
planar YUV 4:4:4,36bpp, (1 Cr & Cb sample per 1x1 Y samples), 12b alpha, big-endian
@ AV_PIX_FMT_NV42
as above, but U and V bytes are swapped
@ AV_PIX_FMT_YUV420P14LE
planar YUV 4:2:0,21bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
@ AV_PIX_FMT_YUV440P
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
@ AV_PIX_FMT_YUV440P10BE
planar YUV 4:4:0,20bpp, (1 Cr & Cb sample per 1x2 Y samples), big-endian
@ AV_PIX_FMT_NV21
as above, but U and V bytes are swapped
@ AV_PIX_FMT_GBRPF32BE
IEEE-754 single precision planar GBR 4:4:4, 96bpp, big-endian.
@ AV_PIX_FMT_MONOBLACK
Y , 1bpp, 0 is black, 1 is white, in each byte pixels are ordered from the msb to the lsb.
@ AV_PIX_FMT_BGR565BE
packed BGR 5:6:5, 16bpp, (msb) 5B 6G 5R(lsb), big-endian
@ AV_PIX_FMT_YUVA422P12BE
planar YUV 4:2:2,24bpp, (1 Cr & Cb sample per 2x1 Y samples), 12b alpha, big-endian
@ AV_PIX_FMT_YUVA444P9LE
planar YUV 4:4:4 36bpp, (1 Cr & Cb sample per 1x1 Y & A samples), little-endian
@ AV_PIX_FMT_BGR0
packed BGR 8:8:8, 32bpp, BGRXBGRX... X=unused/undefined
@ AV_PIX_FMT_YUVA444P10LE
planar YUV 4:4:4 40bpp, (1 Cr & Cb sample per 1x1 Y & A samples, little-endian)
@ AV_PIX_FMT_GBRP9LE
planar GBR 4:4:4 27bpp, little-endian
@ AV_PIX_FMT_YUV444P14BE
planar YUV 4:4:4,42bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
@ AV_PIX_FMT_YUVA420P10BE
planar YUV 4:2:0 25bpp, (1 Cr & Cb sample per 2x2 Y & A samples, big-endian)
@ AV_PIX_FMT_YUVA422P12LE
planar YUV 4:2:2,24bpp, (1 Cr & Cb sample per 2x1 Y samples), 12b alpha, little-endian
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
@ AV_PIX_FMT_BAYER_GRBG16LE
bayer, GRGR..(odd line), BGBG..(even line), 16-bit samples, little-endian
@ AV_PIX_FMT_P016LE
like NV12, with 16bpp per component, little-endian
@ AV_PIX_FMT_P010BE
like NV12, with 10bpp per component, data in the high bits, zeros in the low bits,...
@ AV_PIX_FMT_AYUV64LE
packed AYUV 4:4:4,64bpp (1 Cr & Cb sample per 1x1 Y & A samples), little-endian
@ AV_PIX_FMT_ARGB
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
@ AV_PIX_FMT_RGB555BE
packed RGB 5:5:5, 16bpp, (msb)1X 5R 5G 5B(lsb), big-endian , X=unused/undefined
@ AV_PIX_FMT_YVYU422
packed YUV 4:2:2, 16bpp, Y0 Cr Y1 Cb
@ AV_PIX_FMT_GBRP12BE
planar GBR 4:4:4 36bpp, big-endian
@ AV_PIX_FMT_YUVA422P9LE
planar YUV 4:2:2 27bpp, (1 Cr & Cb sample per 2x1 Y & A samples), little-endian
@ AV_PIX_FMT_GRAY12LE
Y , 12bpp, little-endian.
@ AV_PIX_FMT_GBRAP12BE
planar GBR 4:4:4:4 48bpp, big-endian
@ AV_PIX_FMT_YUV420P9LE
planar YUV 4:2:0, 13.5bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
@ AV_PIX_FMT_BGRA
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
@ AV_PIX_FMT_GRAY12BE
Y , 12bpp, big-endian.
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
@ AV_PIX_FMT_BGR48BE
packed RGB 16:16:16, 48bpp, 16B, 16G, 16R, the 2-byte value for each R/G/B component is stored as big...
@ AV_PIX_FMT_YA16LE
16 bits gray, 16 bits alpha (little-endian)
@ AV_PIX_FMT_YUVA420P10LE
planar YUV 4:2:0 25bpp, (1 Cr & Cb sample per 2x2 Y & A samples, little-endian)
@ AV_PIX_FMT_GRAY14LE
Y , 14bpp, little-endian.
@ AV_PIX_FMT_UYVY422
packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1
@ AV_PIX_FMT_Y210LE
packed YUV 4:2:2 like YUYV422, 20bpp, data in the high bits, little-endian
@ AV_PIX_FMT_RGB48BE
packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as big...
@ AV_PIX_FMT_ABGR
packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
@ AV_PIX_FMT_YUVA420P
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
@ AV_PIX_FMT_YUV422P10BE
planar YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
@ AV_PIX_FMT_P016BE
like NV12, with 16bpp per component, big-endian
@ AV_PIX_FMT_YUVA422P10LE
planar YUV 4:2:2 30bpp, (1 Cr & Cb sample per 2x1 Y & A samples, little-endian)
@ AV_PIX_FMT_YUV420P10LE
planar YUV 4:2:0, 15bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
@ AV_PIX_FMT_YUVJ440P
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV440P and setting color_range
@ AV_PIX_FMT_YUV410P
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
@ AV_PIX_FMT_RGBA64BE
packed RGBA 16:16:16:16, 64bpp, 16R, 16G, 16B, 16A, the 2-byte value for each R/G/B/A component is st...
@ AV_PIX_FMT_RGB8
packed RGB 3:3:2, 8bpp, (msb)2R 3G 3B(lsb)
@ AV_PIX_FMT_NV24
planar YUV 4:4:4, 24bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (firs...
@ AV_PIX_FMT_RGBA64LE
packed RGBA 16:16:16:16, 64bpp, 16R, 16G, 16B, 16A, the 2-byte value for each R/G/B/A component is st...
@ AV_PIX_FMT_0BGR
packed BGR 8:8:8, 32bpp, XBGRXBGR... X=unused/undefined
@ AV_PIX_FMT_YUV411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
@ AV_PIX_FMT_YUV422P16LE
planar YUV 4:2:2, 32bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
@ AV_PIX_FMT_YUV420P14BE
planar YUV 4:2:0,21bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
@ AV_PIX_FMT_GBRAP16BE
planar GBRA 4:4:4:4 64bpp, big-endian
@ AV_PIX_FMT_YUV444P14LE
planar YUV 4:4:4,42bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
@ AV_PIX_FMT_BAYER_RGGB16LE
bayer, RGRG..(odd line), GBGB..(even line), 16-bit samples, little-endian
@ AV_PIX_FMT_GBRPF32LE
IEEE-754 single precision planar GBR 4:4:4, 96bpp, little-endian.
@ AV_PIX_FMT_YUVA444P9BE
planar YUV 4:4:4 36bpp, (1 Cr & Cb sample per 1x1 Y & A samples), big-endian
@ AV_PIX_FMT_YUV422P12LE
planar YUV 4:2:2,24bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
@ AV_PIX_FMT_BGR8
packed RGB 3:3:2, 8bpp, (msb)2B 3G 3R(lsb)
@ AV_PIX_FMT_RGB444LE
packed RGB 4:4:4, 16bpp, (msb)4X 4R 4G 4B(lsb), little-endian, X=unused/undefined
@ AV_PIX_FMT_YUV444P10BE
planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
@ AV_PIX_FMT_YUV440P12LE
planar YUV 4:4:0,24bpp, (1 Cr & Cb sample per 1x2 Y samples), little-endian
@ AV_PIX_FMT_RGB4_BYTE
packed RGB 1:2:1, 8bpp, (msb)1R 2G 1B(lsb)
@ AV_PIX_FMT_BGR4_BYTE
packed RGB 1:2:1, 8bpp, (msb)1B 2G 1R(lsb)
@ AV_PIX_FMT_YUVA420P9LE
planar YUV 4:2:0 22.5bpp, (1 Cr & Cb sample per 2x2 Y & A samples), little-endian
@ AV_PIX_FMT_RGBA
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
@ AV_PIX_FMT_XYZ12BE
packed XYZ 4:4:4, 36 bpp, (msb) 12X, 12Y, 12Z (lsb), the 2-byte value for each X/Y/Z is stored as big...
@ AV_PIX_FMT_YUV444P9LE
planar YUV 4:4:4, 27bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
@ AV_PIX_FMT_YUVA444P
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
@ AV_PIX_FMT_BAYER_GRBG8
bayer, GRGR..(odd line), BGBG..(even line), 8-bit samples
@ AV_PIX_FMT_YUVJ411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples) full scale (JPEG), deprecated in favor ...
@ AV_PIX_FMT_GBRAP
planar GBRA 4:4:4:4 32bpp
@ AV_PIX_FMT_GBRP12LE
planar GBR 4:4:4 36bpp, little-endian
@ AV_PIX_FMT_GRAY9BE
Y , 9bpp, big-endian.
@ AV_PIX_FMT_YUVA444P16LE
planar YUV 4:4:4 64bpp, (1 Cr & Cb sample per 1x1 Y & A samples, little-endian)
@ AV_PIX_FMT_YUVA422P10BE
planar YUV 4:2:2 30bpp, (1 Cr & Cb sample per 2x1 Y & A samples, big-endian)
@ AV_PIX_FMT_UYYVYY411
packed YUV 4:1:1, 12bpp, Cb Y0 Y1 Cr Y2 Y3
@ AV_PIX_FMT_YUVA422P16BE
planar YUV 4:2:2 48bpp, (1 Cr & Cb sample per 2x1 Y & A samples, big-endian)
@ AV_PIX_FMT_BGRA64BE
packed RGBA 16:16:16:16, 64bpp, 16B, 16G, 16R, 16A, the 2-byte value for each R/G/B/A component is st...
@ AV_PIX_FMT_RGB565LE
packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), little-endian
@ AV_PIX_FMT_BAYER_BGGR16BE
bayer, BGBG..(odd line), GRGR..(even line), 16-bit samples, big-endian
@ AV_PIX_FMT_GBRP16BE
planar GBR 4:4:4 48bpp, big-endian
@ AV_PIX_FMT_GBRAP12LE
planar GBR 4:4:4:4 48bpp, little-endian
@ AV_PIX_FMT_GBRP9BE
planar GBR 4:4:4 27bpp, big-endian
@ AV_PIX_FMT_YUVA420P16LE
planar YUV 4:2:0 40bpp, (1 Cr & Cb sample per 2x2 Y & A samples, little-endian)
@ AV_PIX_FMT_RGB555LE
packed RGB 5:5:5, 16bpp, (msb)1X 5R 5G 5B(lsb), little-endian, X=unused/undefined
@ AV_PIX_FMT_BGR444BE
packed BGR 4:4:4, 16bpp, (msb)4X 4B 4G 4R(lsb), big-endian, X=unused/undefined
@ AV_PIX_FMT_RGB48LE
packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as lit...
@ AV_PIX_FMT_BGR555BE
packed BGR 5:5:5, 16bpp, (msb)1X 5B 5G 5R(lsb), big-endian , X=unused/undefined
@ AV_PIX_FMT_GBRAPF32BE
IEEE-754 single precision planar GBRA 4:4:4:4, 128bpp, big-endian.
@ AV_PIX_FMT_BGR444LE
packed BGR 4:4:4, 16bpp, (msb)4X 4B 4G 4R(lsb), little-endian, X=unused/undefined
@ AV_PIX_FMT_YUVA420P16BE
planar YUV 4:2:0 40bpp, (1 Cr & Cb sample per 2x2 Y & A samples, big-endian)
@ AV_PIX_FMT_YUV420P12LE
planar YUV 4:2:0,18bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
@ AV_PIX_FMT_BAYER_RGGB16BE
bayer, RGRG..(odd line), GBGB..(even line), 16-bit samples, big-endian
@ AV_PIX_FMT_X2RGB10LE
packed RGB 10:10:10, 30bpp, (msb)2X 10R 10G 10B(lsb), little-endian, X=unused/undefined
@ AV_PIX_FMT_YUVJ422P
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
@ AV_PIX_FMT_YUV444P9BE
planar YUV 4:4:4, 27bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
@ AV_PIX_FMT_GBRAPF32LE
IEEE-754 single precision planar GBRA 4:4:4:4, 128bpp, little-endian.
@ AV_PIX_FMT_YUV422P9LE
planar YUV 4:2:2, 18bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
@ AV_PIX_FMT_GRAYF32BE
IEEE-754 single precision Y, 32bpp, big-endian.
@ AV_PIX_FMT_RGB444BE
packed RGB 4:4:4, 16bpp, (msb)4X 4R 4G 4B(lsb), big-endian, X=unused/undefined
@ AV_PIX_FMT_YUV422P9BE
planar YUV 4:2:2, 18bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
@ AV_PIX_FMT_BGR48LE
packed RGB 16:16:16, 48bpp, 16B, 16G, 16R, the 2-byte value for each R/G/B component is stored as lit...
@ AV_PIX_FMT_GBRP14LE
planar GBR 4:4:4 42bpp, little-endian
@ AV_PIX_FMT_RGB0
packed RGB 8:8:8, 32bpp, RGBXRGBX... X=unused/undefined
@ AV_PIX_FMT_YUV422P10LE
planar YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
@ AV_PIX_FMT_GRAY16LE
Y , 16bpp, little-endian.
@ AV_PIX_FMT_YUVA422P
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
@ AV_PIX_FMT_GBRP10LE
planar GBR 4:4:4 30bpp, little-endian
@ AV_PIX_FMT_GBRAP10BE
planar GBR 4:4:4:4 40bpp, big-endian
@ AV_PIX_FMT_BAYER_GRBG16BE
bayer, GRGR..(odd line), BGBG..(even line), 16-bit samples, big-endian
@ AV_PIX_FMT_RGB565BE
packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), big-endian
@ AV_PIX_FMT_BGR555LE
packed BGR 5:5:5, 16bpp, (msb)1X 5B 5G 5R(lsb), little-endian, X=unused/undefined
@ AV_PIX_FMT_YUV420P12BE
planar YUV 4:2:0,18bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
@ AV_PIX_FMT_BGRA64LE
packed RGBA 16:16:16:16, 64bpp, 16B, 16G, 16R, 16A, the 2-byte value for each R/G/B/A component is st...
@ AV_PIX_FMT_YUV440P12BE
planar YUV 4:4:0,24bpp, (1 Cr & Cb sample per 1x2 Y samples), big-endian
@ AV_PIX_FMT_GBRAP10LE
planar GBR 4:4:4:4 40bpp, little-endian
@ AV_PIX_FMT_YUYV422
packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr
@ AV_PIX_FMT_YUV422P16BE
planar YUV 4:2:2, 32bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
@ AV_PIX_FMT_BAYER_GBRG16LE
bayer, GBGB..(odd line), RGRG..(even line), 16-bit samples, little-endian
@ AV_PIX_FMT_PAL8
8 bits with AV_PIX_FMT_RGB32 palette
@ AV_PIX_FMT_BGR24
packed RGB 8:8:8, 24bpp, BGRBGR...
@ AV_PIX_FMT_GRAY9LE
Y , 9bpp, little-endian.
@ AV_PIX_FMT_GBRP
planar GBR 4:4:4 24bpp
@ AV_PIX_FMT_YUV422P14LE
planar YUV 4:2:2,28bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
@ AV_PIX_FMT_GBRAP16LE
planar GBRA 4:4:4:4 64bpp, little-endian
@ AV_PIX_FMT_BAYER_BGGR16LE
bayer, BGBG..(odd line), GRGR..(even line), 16-bit samples, little-endian
@ AV_PIX_FMT_YUV420P10BE
planar YUV 4:2:0, 15bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
@ AV_PIX_FMT_YUV420P9BE
The following 12 formats have the disadvantage of needing 1 format for each bit depth.
@ AV_PIX_FMT_GRAY10BE
Y , 10bpp, big-endian.
@ AV_PIX_FMT_YUVA444P10BE
planar YUV 4:4:4 40bpp, (1 Cr & Cb sample per 1x1 Y & A samples, big-endian)
@ AV_PIX_FMT_YUV440P10LE
planar YUV 4:4:0,20bpp, (1 Cr & Cb sample per 1x2 Y samples), little-endian
@ AV_PIX_FMT_YA8
8 bits gray, 8 bits alpha
@ AV_PIX_FMT_YUV444P16LE
planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
@ AV_PIX_FMT_0RGB
packed RGB 8:8:8, 32bpp, XRGBXRGB... X=unused/undefined
@ AV_PIX_FMT_GRAY14BE
Y , 14bpp, big-endian.
@ AV_PIX_FMT_GBRP14BE
planar GBR 4:4:4 42bpp, big-endian
@ AV_PIX_FMT_BGR565LE
packed BGR 5:6:5, 16bpp, (msb) 5B 6G 5R(lsb), little-endian
@ AV_PIX_FMT_YUV422P14BE
planar YUV 4:2:2,28bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
@ AV_PIX_FMT_BAYER_GBRG16BE
bayer, GBGB..(odd line), RGRG..(even line), 16-bit samples, big-endian
@ AV_PIX_FMT_YUVJ444P
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
@ AV_PIX_FMT_YUV444P12BE
planar YUV 4:4:4,36bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
@ AV_PIX_FMT_YUVA444P16BE
planar YUV 4:4:4 64bpp, (1 Cr & Cb sample per 1x1 Y & A samples, big-endian)
@ AV_PIX_FMT_YUVA422P16LE
planar YUV 4:2:2 48bpp, (1 Cr & Cb sample per 2x1 Y & A samples, little-endian)
@ AV_PIX_FMT_BAYER_RGGB8
bayer, RGRG..(odd line), GBGB..(even line), 8-bit samples
@ AV_PIX_FMT_GBRP16LE
planar GBR 4:4:4 48bpp, little-endian
@ AV_PIX_FMT_YUVA422P9BE
planar YUV 4:2:2 27bpp, (1 Cr & Cb sample per 2x1 Y & A samples), big-endian
@ AV_PIX_FMT_RGB4
packed RGB 1:2:1 bitstream, 4bpp, (msb)1R 2G 1B(lsb), a byte contains two pixels, the first pixel in ...
@ AV_PIX_FMT_YUVA444P12LE
planar YUV 4:4:4,36bpp, (1 Cr & Cb sample per 1x1 Y samples), 12b alpha, little-endian
@ AV_PIX_FMT_MONOWHITE
Y , 1bpp, 0 is white, 1 is black, in each byte pixels are ordered from the msb to the lsb.
@ AV_PIX_FMT_BGR4
packed RGB 1:2:1 bitstream, 4bpp, (msb)1B 2G 1R(lsb), a byte contains two pixels, the first pixel in ...
@ AV_PIX_FMT_YUV444P10LE
planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
@ AV_PIX_FMT_YUVJ420P
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
@ AV_PIX_FMT_YUV422P12BE
planar YUV 4:2:2,24bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
@ AV_PIX_FMT_BAYER_BGGR8
bayer, BGBG..(odd line), GRGR..(even line), 8-bit samples
@ AV_PIX_FMT_YUV420P16LE
planar YUV 4:2:0, 24bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
@ AV_PIX_FMT_YUV444P12LE
planar YUV 4:4:4,36bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
#define AV_PIX_FMT_BGR565
#define AV_PIX_FMT_YUV422P16
#define AV_PIX_FMT_BGRA64
#define AV_PIX_FMT_GRAY16
#define AV_PIX_FMT_GBRP16
#define AV_PIX_FMT_YUV444P16
#define AV_PIX_FMT_YUV444P10
#define PPC_ALTIVEC(flags)
static const uint16_t table[]
av_cold void ff_sws_rgb2rgb_init(void)
#define FF_ARRAY_ELEMS(a)
int ff_free_filters(SwsContext *c)
int ff_init_filters(SwsContext *c)
static int shift(int a, int b)
Describe the class of an AVClass context structure.
int depth
Number of bits in the component.
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
uint8_t is_supported_endianness
int flag
flag associated to the algorithm
int size_factor
size factor used when initing the filters
const char * description
human-readable description
int dstW
Width of destination luma/alpha planes.
int dstH
Height of destination luma/alpha planes.
int srcW
Width of source luma/alpha planes.
int flags
Flags passed by the user to select scaler algorithm, optimizations, subsampling, etc....
double param[2]
Input parameters for scaling algorithms that need them.
enum AVPixelFormat dstFormat
Destination pixel format.
int srcH
Height of source luma/alpha planes.
enum AVPixelFormat srcFormat
Source pixel format.
double * coeff
pointer to the list of coefficients
int length
number of coefficients in the vector
av_cold void ff_sws_init_range_convert(SwsContext *c)
SwsFunc ff_getSwsFunc(SwsContext *c)
Return function pointer to fastest main scaler path function depending on architecture and available ...
static av_always_inline int isBayer(enum AVPixelFormat pix_fmt)
int ff_init_hscaler_mmxext(int dstW, int xInc, uint8_t *filterCode, int16_t *filter, int32_t *filterPos, int numSplits)
static av_always_inline int isFloat(enum AVPixelFormat pix_fmt)
static av_always_inline int isAnyRGB(enum AVPixelFormat pix_fmt)
void ff_get_unscaled_swscale(SwsContext *c)
Set c->swscale to an unscaled converter if one exists for the specific source and destination formats...
static av_always_inline int is16BPS(enum AVPixelFormat pix_fmt)
#define RETCODE_USE_CASCADE
int ff_yuv2rgb_c_init_tables(SwsContext *c, const int inv_table[4], int fullRange, int brightness, int contrast, int saturation)
static av_always_inline int isPlanarRGB(enum AVPixelFormat pix_fmt)
static av_always_inline int isBayer16BPS(enum AVPixelFormat pix_fmt)
static av_always_inline int isNBPS(enum AVPixelFormat pix_fmt)
const int32_t ff_yuv2rgb_coeffs[11][4]
static av_always_inline int isYUV(enum AVPixelFormat pix_fmt)
#define av_malloc_array(a, b)
static void error(const char *err)
static const double coeff[2][5]
static av_always_inline int diff(const uint32_t a, const uint32_t b)
#define INLINE_MMXEXT(flags)
#define INLINE_MMX(flags)
#define INLINE_AMD3DNOW(flags)
av_cold void ff_yuv2rgb_init_tables_ppc(SwsContext *c, const int inv_table[4], int brightness, int contrast, int saturation)