24#define _DEFAULT_SOURCE
56#if CONFIG_SWSCALE_VULKAN
77 int flags,
const double *param)
111 int filterSize, int16_t *
filter,
120 if ((
c->srcBpc == 8) && (
c->dstBpc <= 14)) {
121 int16_t *filterCopy =
NULL;
122 if (filterSize > 4) {
126 memcpy(filterCopy,
filter, dstW * filterSize *
sizeof(int16_t));
130 for (
i = 0;
i + 16 <= dstW;
i += 16) {
131 FFSWAP(
int, filterPos[
i + 2], filterPos[
i + 4]);
132 FFSWAP(
int, filterPos[
i + 3], filterPos[
i + 5]);
133 FFSWAP(
int, filterPos[
i + 10], filterPos[
i + 12]);
134 FFSWAP(
int, filterPos[
i + 11], filterPos[
i + 13]);
136 if (filterSize > 4) {
138 for (
i = 0;
i + 16 <= dstW;
i += 16) {
140 for (k = 0; k + 4 <= filterSize; k += 4) {
141 for (j = 0; j < 16; ++j) {
142 int from = (
i + j) * filterSize + k;
143 int to =
i * filterSize + j * 4 + k * 16;
144 memcpy(&
filter[
to], &filterCopy[
from], 4 *
sizeof(int16_t));
149 for (;
i < dstW;
i += 4) {
151 int rem = dstW -
i >= 4 ? 4 : dstW -
i;
152 for (k = 0; k + 4 <= filterSize; k += 4) {
153 for (j = 0; j < rem; ++j) {
154 int from = (
i + j) * filterSize + k;
155 int to =
i * filterSize + j * 4 + k * 4;
156 memcpy(&
filter[
to], &filterCopy[
from], 4 *
sizeof(int16_t));
172 return ((d * dist +
c) * dist +
b) * dist +
a;
175 b + 2.0 *
c + 3.0 * d,
177 -
b - 3.0 *
c - 6.0 * d,
183 if (
pos == -1 ||
pos <= -513) {
184 pos = (128 << chr_subsample) - 128;
187 return pos >> chr_subsample;
209 {
SWS_POINT,
"nearest neighbor / point", -1 },
212 {
SWS_X,
"experimental", 8 },
216 int *outFilterSize,
int xInc,
int srcW,
217 int dstW,
int filterAlign,
int one,
237 if (
FFABS(xInc - 0x10000) < 10 && srcPos == dstPos) {
243 for (
i = 0;
i < dstW;
i++) {
254 xDstInSrc = ((dstPos*(
int64_t)xInc)>>8) - ((srcPos*0x8000LL)>>7);
255 for (
i = 0;
i < dstW;
i++) {
256 int xx = (xDstInSrc - ((filterSize - 1) << 15) + (1 << 15)) >> 16;
258 (*filterPos)[
i] = xx;
262 }
else if ((xInc <= (1 << 16) && (scaler ==
SWS_AREA)) ||
270 xDstInSrc = ((dstPos*(
int64_t)xInc)>>8) - ((srcPos*0x8000LL)>>7);
271 for (
i = 0;
i < dstW;
i++) {
272 int xx = (xDstInSrc - ((filterSize - 1) << 15) + (1 << 15)) >> 16;
275 (*filterPos)[
i] = xx;
277 for (j = 0; j < filterSize; j++) {
281 filter[
i * filterSize + j] = coeff;
300 if (sizeFactor > 50) {
306 filterSize = 1 + sizeFactor;
308 filterSize = 1 + (sizeFactor * srcW + dstW - 1) / dstW;
310 filterSize =
FFMIN(filterSize, srcW - 2);
311 filterSize =
FFMAX(filterSize, 1);
316 xDstInSrc = ((dstPos*(
int64_t)xInc)>>7) - ((srcPos*0x10000LL)>>7);
317 for (
i = 0;
i < dstW;
i++) {
318 int xx = (xDstInSrc - (filterSize - 2) * (1LL<<16)) / (1 << 17);
320 (*filterPos)[
i] = xx;
321 for (j = 0; j < filterSize; j++) {
328 floatd = d * (1.0 / (1 << 30));
334 if (d >= 1LL << 31) {
341 coeff = (12 * (1 << 24) - 9 *
B - 6 *
C) * ddd +
342 (-18 * (1 << 24) + 12 *
B + 6 *
C) * dd +
343 (6 * (1 << 24) - 2 *
B) * (1 << 30);
345 coeff = (-
B - 6 *
C) * ddd +
346 (6 *
B + 30 *
C) * dd +
347 (-12 *
B - 48 *
C) * d +
348 (8 *
B + 24 *
C) * (1 << 30);
350 coeff /= (1LL<<54)/fone;
351 }
else if (scaler ==
SWS_X) {
356 c = cos(floatd *
M_PI);
363 coeff = (
c * 0.5 + 0.5) * fone;
366 if (d2 * xInc < -(1LL << (29 + 16)))
367 coeff = 1.0 * (1LL << (30 + 16));
368 else if (d2 * xInc < (1LL << (29 + 16)))
369 coeff = -d2 * xInc + (1LL << (29 + 16));
372 coeff *= fone >> (30 + 16);
375 coeff = exp2(-p * floatd * floatd) * fone;
377 coeff = (d ? sin(floatd *
M_PI) / (floatd *
M_PI) : 1.0) * fone;
380 coeff = (d ? sin(floatd *
M_PI) * sin(floatd *
M_PI / p) /
381 (floatd * floatd *
M_PI *
M_PI / p) : 1.0) * fone;
385 coeff = (1 << 30) - d;
390 double p = -2.196152422706632;
396 filter[
i * filterSize + j] = coeff;
399 xDstInSrc += 2LL * xInc;
407 filter2Size = filterSize;
409 filter2Size += srcFilter->
length - 1;
411 filter2Size += dstFilter->
length - 1;
413 filter2 =
av_calloc(dstW, filter2Size *
sizeof(*filter2));
416 for (
i = 0;
i < dstW;
i++) {
420 for (k = 0; k < srcFilter->
length; k++) {
421 for (j = 0; j < filterSize; j++)
422 filter2[
i * filter2Size + k + j] +=
426 for (j = 0; j < filterSize; j++)
427 filter2[
i * filter2Size + j] =
filter[
i * filterSize + j];
431 (*filterPos)[
i] += (filterSize - 1) / 2 - (filter2Size - 1) / 2;
438 for (
i = dstW - 1;
i >= 0;
i--) {
439 int min = filter2Size;
444 for (j = 0; j < filter2Size; j++) {
446 cutOff +=
FFABS(filter2[
i * filter2Size]);
453 if (
i < dstW - 1 && (*filterPos)[
i] >= (*filterPos)[
i + 1])
457 for (k = 1; k < filter2Size; k++)
458 filter2[
i * filter2Size + k - 1] = filter2[
i * filter2Size + k];
459 filter2[
i * filter2Size + k - 1] = 0;
465 for (j = filter2Size - 1; j > 0; j--) {
466 cutOff +=
FFABS(filter2[
i * filter2Size + j]);
473 if (
min > minFilterSize)
479 if (minFilterSize < 5)
485 if (minFilterSize < 3)
491 if (minFilterSize == 1 && filterAlign == 2)
496 int reNum = minFilterSize & (0x07);
498 if (minFilterSize < 5)
505 filterSize = (minFilterSize + (filterAlign - 1)) & (~(filterAlign - 1));
518 "SwScaler: reducing / aligning filtersize %d -> %d\n",
519 filter2Size, filterSize);
521 for (
i = 0;
i < dstW;
i++) {
524 for (j = 0; j < filterSize; j++) {
525 if (j >= filter2Size)
526 filter[
i * filterSize + j] = 0;
528 filter[
i * filterSize + j] = filter2[
i * filter2Size + j];
530 filter[
i * filterSize + j] = 0;
537 for (
i = 0;
i < dstW;
i++) {
539 if ((*filterPos)[
i] < 0) {
541 for (j = 1; j < filterSize; j++) {
544 filter[
i * filterSize + j] = 0;
549 if ((*filterPos)[
i] + filterSize > srcW) {
550 int shift = (*filterPos)[
i] +
FFMIN(filterSize - srcW, 0);
553 for (j = filterSize - 1; j >= 0; j--) {
554 if ((*filterPos)[
i] + j >= srcW) {
555 acc +=
filter[
i * filterSize + j];
556 filter[
i * filterSize + j] = 0;
559 for (j = filterSize - 1; j >= 0; j--) {
561 filter[
i * filterSize + j] = 0;
568 filter[
i * filterSize + srcW - 1 - (*filterPos)[
i]] += acc;
572 if ((*filterPos)[
i] + filterSize > srcW) {
573 for (j = 0; j < filterSize; j++) {
579 *outFilterSize =
FFMIN(filterSize,
FFALIGN(srcW, filterAlign));
583 *outFilter =
av_calloc(dstW + 3, *outFilterSize *
sizeof(**outFilter));
588 for (
i = 0;
i < dstW;
i++) {
593 for (j = 0; j < filterSize; j++) {
594 sum +=
filter[
i * filterSize + j];
596 sum = (sum + one / 2) / one;
601 for (j = 0; j < *outFilterSize; j++) {
604 (*outFilter)[
i * (*outFilterSize) + j] = intV;
605 error = v - intV * sum;
609 (*filterPos)[dstW + 0] =
610 (*filterPos)[dstW + 1] =
611 (*filterPos)[dstW + 2] = (*filterPos)[dstW - 1];
613 for (
i = 0;
i < *outFilterSize;
i++) {
614 int k = (dstW - 1) * (*outFilterSize) +
i;
615 (*outFilter)[k + 1 * (*outFilterSize)] =
616 (*outFilter)[k + 2 * (*outFilterSize)] =
617 (*outFilter)[k + 3 * (*outFilterSize)] = (*outFilter)[k];
642 uint8_t *p = (uint8_t*)
c->input_rgb2yuv_table;
644 static const int8_t
map[] = {
669 -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 ,
670 -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 ,
671 -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 ,
672 -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 ,
673 -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 ,
674 -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 ,
675 -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 ,
676 -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 ,
739 for (
int i = 0;
i < 4096;
i++)
741 for (
int i = 0;
i < 65536;
i++)
742 luts->
out[
i] =
lrint(from_linear(
i / 65535.0 * peak_out) * 4095.0);
764 for (
int i = 0;
i < 3;
i++) {
765 for (
int j = 0; j < 3; j++) {
766 const double v = m->
m[
i][j] *
scale * 4096.0;
782 if (
c->xyz2rgb.gamma.in)
789 c->xyz2rgb.gamma.in =
av_malloc(
sizeof(uint16_t) * 2 * (4096 + 65536));
790 if (!
c->xyz2rgb.gamma.in)
792 c->rgb2xyz.gamma.in =
c->xyz2rgb.gamma.in + 4096;
793 c->xyz2rgb.gamma.out =
c->rgb2xyz.gamma.in + 4096;
794 c->rgb2xyz.gamma.out =
c->xyz2rgb.gamma.out + 65536;
882 if (
c->srcXYZ ||
c->dstXYZ)
894 int srcRange,
const int table[4],
int dstRange,
900 int ret, need_reinit = 0;
902 if (
c->nb_slice_ctx) {
904 for (
int i = 0;
i <
c->nb_slice_ctx;
i++) {
906 srcRange,
table, dstRange,
932 c->brightness != brightness ||
933 c->contrast != contrast ||
935 memcmp(
c->srcColorspaceTable, inv_table,
sizeof(
int) * 4) ||
936 memcmp(
c->dstColorspaceTable,
table,
sizeof(
int) * 4)
940 memmove(
c->srcColorspaceTable, inv_table,
sizeof(
int) * 4);
941 memmove(
c->dstColorspaceTable,
table,
sizeof(
int) * 4);
945 c->brightness = brightness;
946 c->contrast = contrast;
957 if (
c->cascaded_context[
c->cascaded_mainindex])
964 if (!
c->cascaded_context[0] &&
965 memcmp(
c->dstColorspaceTable,
c->srcColorspaceTable,
sizeof(
int) * 4) &&
968 int tmp_width, tmp_height;
969 int srcW = sws->
src_w;
970 int srcH = sws->
src_h;
971 int dstW = sws->
dst_w;
972 int dstH = sws->
dst_h;
974 av_log(
c,
AV_LOG_VERBOSE,
"YUV color matrix differs for YUV->YUV, using intermediate RGB to convert\n");
999 tmp_width, tmp_height, tmp_format, 64);
1004 tmp_width, tmp_height, tmp_format,
1006 if (!
c->cascaded_context[0])
1009 c->cascaded_context[0]->alpha_blend = sws->
alpha_blend;
1016 srcRange,
table, dstRange,
1019 c->cascaded_context[1] =
alloc_set_opts(tmp_width, tmp_height, tmp_format,
1022 if (!
c->cascaded_context[1])
1024 c->cascaded_context[1]->src_range = srcRange;
1025 c->cascaded_context[1]->dst_range = dstRange;
1031 srcRange,
table, dstRange,
1032 0, 1 << 16, 1 << 16);
1036 if (
c->cascaded_context[0] && memcmp(
c->dstColorspaceTable,
c->srcColorspaceTable,
sizeof(
int) * 4))
1058 int *srcRange,
int **
table,
int *dstRange,
1059 int *brightness,
int *contrast,
int *
saturation)
1065 if (
c->nb_slice_ctx) {
1067 table, dstRange, brightness, contrast,
1071 *inv_table =
c->srcColorspaceTable;
1072 *
table =
c->dstColorspaceTable;
1075 *brightness =
c->brightness;
1076 *contrast =
c->contrast;
1100 tbl = (uint16_t*)
av_malloc(
sizeof(uint16_t) * 1 << 16);
1104 for (
i = 0;
i < 65536; ++
i) {
1105 tbl[
i] = pow(
i / 65535.0, e) * 65535.0;
1191 int usesVFilter, usesHFilter;
1195 int srcW = sws->
src_w;
1196 int srcH = sws->
src_h;
1197 int dstW = sws->
dst_w;
1198 int dstH = sws->
dst_h;
1199 int dst_stride =
FFALIGN(dstW *
sizeof(int16_t) + 66, 16);
1206 static const float float_mult = 1.0f / 255.0f;
1212 unscaled = (srcW == dstW && srcH == dstH);
1214 if (!
c->contrast && !
c->saturation && !
c->dstFormatBpp)
1260 if (dstW < srcW && dstH < srcH)
1262 else if (dstW > srcW && dstH > srcH)
1268 }
else if (
i & (
i - 1)) {
1270 "Exactly one scaler algorithm must be chosen, got %X\n",
i);
1276 if (srcW < 8 || dstW <= 8 || srcW >= 65536) {
1291 if (srcW < 1 || srcH < 1 || dstW < 1 || dstH < 1) {
1295 srcW, srcH, dstW, dstH);
1306 dstFilter = &dummyFilter;
1308 srcFilter = &dummyFilter;
1314 c->vRounder = 4 * 0x0001000100010001ULL;
1316 usesVFilter = (srcFilter->
lumV && srcFilter->
lumV->
length > 1) ||
1320 usesHFilter = (srcFilter->
lumH && srcFilter->
lumH->
length > 1) ||
1328 c->dst_slice_align = 1 <<
c->chrDstVSubSample;
1337 if (
c->chrSrcHSubSample == 0
1338 &&
c->chrSrcVSubSample == 0
1342 av_log(
c,
AV_LOG_DEBUG,
"Forcing full internal H chroma due to input having non subsampled chroma\n");
1362 "Desired dithering only supported in full chroma interpolation for destination format '%s'\n",
1371 "Ordered dither is not supported in full chroma interpolation for destination format '%s'\n",
1380 "%s output is not supported with half chroma resolution, switching to full\n",
1418 "full chroma interpolation for destination format '%s' not yet implemented\n",
1424 c->chrDstHSubSample = 1;
1429 c->chrSrcVSubSample +=
c->vChrDrop;
1452 ((dstW >>
c->chrDstHSubSample) <= (srcW >> 1) ||
1454 c->chrSrcHSubSample = 1;
1473 if (
c->dstBpc == 16)
1477 c->canMMXEXTBeUsed = dstW >= srcW && (dstW & 31) == 0 &&
1478 c->chrDstW >=
c->chrSrcW &&
1480 if (!
c->canMMXEXTBeUsed && dstW >= srcW &&
c->chrDstW >=
c->chrSrcW && (srcW & 15) == 0
1485 "output width is not a multiple of 32 -> no MMXEXT scaler\n");
1488 c->canMMXEXTBeUsed = 0;
1490 c->canMMXEXTBeUsed = 0;
1492 int64_t chrXInc = (((
int64_t)
c->chrSrcW << 16) + (
c->chrDstW >> 1)) /
c->chrDstW;
1493 int64_t chrYInc = (((
int64_t)
c->chrSrcH << 16) + (
c->chrDstH >> 1)) /
c->chrDstH;
1503 if (
c->canMMXEXTBeUsed) {
1509 lumXInc = ((
int64_t)(srcW - 2) << 16) / (dstW - 2) - 20;
1510 chrXInc = ((
int64_t)(
c->chrSrcW - 2) << 16) / (
c->chrDstW - 2) - 20;
1513 if (chrXInc < 10 || chrXInc > INT_MAX ||
1514 chrYInc < 10 || chrYInc > INT_MAX ||
1515 lumXInc < 10 || lumXInc > INT_MAX ||
1516 lumYInc < 10 || lumYInc > INT_MAX)
1519 c->lumXInc = lumXInc;
1520 c->lumYInc = lumYInc;
1521 c->chrXInc = chrXInc;
1522 c->chrYInc = chrYInc;
1526 c->gamma_value = 2.2;
1529 if (!unscaled && sws->
gamma_flag && (srcFormat != tmpFmt || dstFormat != tmpFmt)) {
1531 c->cascaded_context[0] =
NULL;
1534 srcW, srcH, tmpFmt, 64);
1541 if (!
c->cascaded_context[0])
1550 flags, srcFilter, dstFilter,
1553 if (!
c->cascaded_context[1])
1557 c2->is_internal_gamma = 1;
1560 if (!
c2->gamma || !
c2->inv_gamma)
1569 c->cascaded_context[1] =
NULL;
1573 c->cascaded_context[2] =
NULL;
1574 if (dstFormat != tmpFmt) {
1576 dstW, dstH, tmpFmt, 64);
1581 dstW, dstH, dstFormat,
1583 if (!
c->cascaded_context[2])
1593 if (!
isGray(srcFormat) &&
1609 srcW, srcH, tmpFormat, 64);
1614 srcW, srcH, tmpFormat,
1617 if (!
c->cascaded_context[0])
1621 dstW, dstH, dstFormat,
1623 if (!
c->cascaded_context[1])
1634 for (
i = 0;
i < 256; ++
i){
1635 c->uint2float_lut[
i] = (
float)
i * float_mult;
1641 (!unscaled || unscaled && dstFormat != srcFormat && (srcFormat !=
AV_PIX_FMT_GRAYF32 ||
1646 if (CONFIG_SWSCALE_ALPHA &&
isALPHA(srcFormat) && !
isALPHA(dstFormat)) {
1651 dstFormat != tmpFormat ||
1652 usesHFilter || usesVFilter ||
1655 c->cascaded_mainindex = 1;
1657 srcW, srcH, tmpFormat, 64);
1662 srcW, srcH, tmpFormat,
1664 if (!
c->cascaded_context[0])
1666 c->cascaded_context[0]->alpha_blend = sws->
alpha_blend;
1672 dstW, dstH, dstFormat,
1674 if (!
c->cascaded_context[1])
1677 c->cascaded_context[1]->src_range = sws->
src_range;
1678 c->cascaded_context[1]->dst_range = sws->
dst_range;
1690 if (unscaled && !usesHFilter && !usesVFilter &&
1700 "using alpha blendaway %s -> %s special converter\n",
1706 if (unscaled && !usesHFilter && !usesVFilter &&
1712 if (
c->convert_unscaled) {
1715 "using unscaled %s -> %s special converter\n",
1723#if HAVE_MMXEXT_INLINE
1733 if (!
c->lumMmxextFilterCode || !
c->chrMmxextFilterCode) {
1745 c->hLumFilter, (uint32_t*)
c->hLumFilterPos, 8);
1747 c->hChrFilter, (uint32_t*)
c->hChrFilterPos, 4);
1764 &
c->hLumFilterSize,
c->lumXInc,
1765 srcW, dstW, filterAlign, 1 << 14,
1775 &
c->hChrFilterSize,
c->chrXInc,
1776 c->chrSrcW,
c->chrDstW, filterAlign, 1 << 14,
1795 c->lumYInc, srcH, dstH, filterAlign, (1 << 12),
1802 if (
ret < 0 && !usecascade)
1804 if ((
ret =
initFilter(&
c->vChrFilter, &
c->vChrFilterPos, &
c->vChrFilterSize,
1805 c->chrYInc,
c->chrSrcH,
c->chrDstH,
1806 filterAlign, (1 << 12),
1826 for (
i = 0;
i < 4;
i++)
1833 c->uv_off = (dst_stride>>1) + 64 / (
c->dstBpc &~ 7);
1834 c->uv_offx2 = dst_stride + 16;
1839 const char *scaler =
NULL, *cpucaps;
1848 scaler =
"ehh flags invalid?!";
1863 cpucaps =
"AltiVec";
1871 "lum srcW=%d srcH=%d dstW=%d dstH=%d xInc=%d yInc=%d\n",
1874 "chr srcW=%d srcH=%d dstW=%d dstH=%d xInc=%d yInc=%d\n",
1875 c->chrSrcW,
c->chrSrcH,
c->chrDstW,
c->chrDstH,
1876 c->chrXInc,
c->chrYInc);
1886 int tmpW = sqrt(srcW * (
int64_t)dstW);
1887 int tmpH = sqrt(srcH * (
int64_t)dstH);
1893 if (srcW*(
int64_t)srcH <= 4LL*dstW*dstH)
1897 tmpW, tmpH, tmpFormat, 64);
1902 tmpW, tmpH, tmpFormat,
1904 if (!
c->cascaded_context[0])
1912 dstW, dstH, dstFormat,
1914 if (!
c->cascaded_context[1])
1964 "Error-diffusion dither is in use, scaling will be single-threaded.");
1980 c->is_legacy_init = 1;
1983 if (!
c->frame_src || !
c->frame_dst)
2010 SwsFilter *dstFilter,
const double *param)
2015 dstW, dstH, dstFormat,
2031 for (
i=0;
i<
a->length;
i++)
2032 if (isnan(
a->coeff[
i]))
2040 for (
i=0;
i<
a->length;
i++)
2048 if(length <= 0 || length > INT_MAX/
sizeof(
double))
2063 const int length = (int)(variance *
quality + 0.5) | 1;
2065 double middle = (length - 1) * 0.5;
2068 if(variance < 0 ||
quality < 0)
2076 for (
i = 0;
i < length;
i++) {
2077 double dist =
i - middle;
2078 vec->
coeff[
i] =
exp(-dist * dist / (2 * variance * variance)) /
2079 sqrt(2 * variance *
M_PI);
2100 for (
i = 0;
i < length;
i++)
2121 for (
i = 0;
i <
a->length;
i++)
2131 for (
i = 0;
i <
a->length;
i++)
2132 a->coeff[
i] *= scalar;
2142 int length =
FFMAX(
a->length,
b->length);
2149 for (
i = 0;
i <
a->length;
i++)
2150 vec->
coeff[
i + (length - 1) / 2 - (
a->length - 1) / 2] +=
a->coeff[
i];
2151 for (
i = 0;
i <
b->length;
i++)
2152 vec->
coeff[
i + (length - 1) / 2 - (
b->length - 1) / 2] +=
b->coeff[
i];
2167 for (
i = 0;
i <
a->length;
i++) {
2168 vec->
coeff[
i + (length - 1) / 2 -
2169 (
a->length - 1) / 2 -
shift] =
a->coeff[
i];
2184 a->coeff = shifted->
coeff;
2215 for (
i = 0;
i <
a->length;
i++)
2216 if (
a->coeff[
i] >
max)
2219 for (
i = 0;
i <
a->length;
i++)
2220 if (
a->coeff[
i] <
min)
2225 for (
i = 0;
i <
a->length;
i++) {
2226 int x = (int)((
a->coeff[
i] -
min) * 60.0 /
range + 0.5);
2227 av_log(log_ctx, log_level,
"%1.3f ",
a->coeff[
i]);
2229 av_log(log_ctx, log_level,
" ");
2230 av_log(log_ctx, log_level,
"|\n");
2256 float lumaSharpen,
float chromaSharpen,
2257 float chromaHShift,
float chromaVShift,
2264 if (lumaGBlur != 0.0) {
2272 if (chromaGBlur != 0.0) {
2283 if (chromaSharpen != 0.0) {
2294 if (lumaSharpen != 0.0) {
2305 if (chromaHShift != 0.0)
2308 if (chromaVShift != 0.0)
2351 for (
i = 0;
i <
c->nb_slice_ctx;
i++)
2357 for (
i = 0;
i < 4;
i++)
2381 c->lumMmxextFilterCode =
NULL;
2382 c->chrMmxextFilterCode =
NULL;
2391 memset(
c->cascaded_context, 0,
sizeof(
c->cascaded_context));
2425 const double *param)
2432 param = default_param;
2434 if (prev && (prev->
src_w == srcW &&
2435 prev->
src_h == srcH &&
2437 prev->
dst_w == dstW &&
2438 prev->
dst_h == dstH &&
2478 for (idx = 0; idx < rl->
nb_ranges; idx++)
2485 if (prev->
start + prev->
len > start)
2488 if (idx < rl->nb_ranges) {
2518 if (idx < rl->nb_ranges - 1) {
2533 int (*
func)(
void *priv,
int jobnr,
int threadnr,
int nb_jobs,
int nb_threads),
2534 int nb_threads,
int nb_jobs)
2540 for (
int i = 0;
i < nb_jobs;
i++) {
2541 int ret =
func(priv,
i, 0, nb_jobs, 1);
2546 }
else if (
ret < 0) {
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
static const char *const format[]
int ff_sws_alphablendaway(SwsInternal *c, const uint8_t *const src[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dst[], const int dstStride[])
static AVFormatContext * ctx
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_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
#define av_assert0(cond)
assert() equivalent, that is always enabled.
static int BS_FUNC left(const BSCTX *bc)
Return the number of the bits left in a buffer.
#define flags(name, subs,...)
#define i(width, name, range_min, range_max)
static IPT saturation(const CmsCtx *ctx, IPT ipt)
#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 ...
Colorspace value utility functions for libavutil.
SwsMatrix3x3 ff_sws_xyz2rgb(const AVColorPrimariesDesc *prim)
SwsMatrix3x3 ff_sws_rgb2xyz(const AVColorPrimariesDesc *desc)
static __device__ float ceil(float a)
static __device__ float fabs(float a)
static float to_linear(float x, float scale)
void ff_sws_graph_free(SwsGraph **pgraph)
Uninitialize any state associate with this filter graph and free it.
#define AVERROR_UNKNOWN
Unknown error, typically from an external library.
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
#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.
double(* av_csp_trc_function)(double)
Function pointer representing a double -> double transfer function that performs either an OETF trans...
av_csp_trc_function av_csp_trc_func_from_id(enum AVColorTransferCharacteristic trc)
Determine the function needed to apply the given AVColorTransferCharacteristic to linear input.
const AVColorPrimariesDesc * av_csp_primaries_desc_from_id(enum AVColorPrimaries prm)
Retrieves a complete gamut description from an enum constant describing the color primaries.
av_csp_trc_function av_csp_trc_func_inv_from_id(enum AVColorTransferCharacteristic trc)
Returns the mathematical inverse of the corresponding TRC function.
void * av_fast_realloc(void *ptr, unsigned int *size, size_t min_size)
Reallocate the given buffer if it is not large enough, otherwise do nothing.
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_freeFilter(SwsFilter *filter)
int sws_getColorspaceDetails(SwsContext *sws, int **inv_table, int *srcRange, int **table, int *dstRange, int *brightness, int *contrast, int *saturation)
av_cold int sws_init_context(SwsContext *sws, SwsFilter *srcFilter, SwsFilter *dstFilter)
Initialize the swscaler context sws_context.
#define SWS_SRC_V_CHR_DROP_MASK
void sws_freeVec(SwsVector *a)
SwsFilter * sws_getDefaultFilter(float lumaGBlur, float chromaGBlur, float lumaSharpen, float chromaSharpen, float chromaHShift, float chromaVShift, int verbose)
int sws_isSupportedEndiannessConversion(enum AVPixelFormat pix_fmt)
SwsContext * sws_alloc_context(void)
Allocate an empty SwsContext and set its fields to default values.
void sws_free_context(SwsContext **pctx)
Free the context and everything associated with it, and write NULL to the provided pointer.
#define SWS_SRC_V_CHR_DROP_SHIFT
SwsVector * sws_allocVec(int length)
Allocate and return an uninitialized vector with length coefficients.
SwsVector * sws_getGaussianVec(double variance, double quality)
Return a normalized Gaussian curve used to filter stuff quality = 3 is high quality,...
SwsContext * sws_getCachedContext(SwsContext *prev, 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.
void sws_normalizeVec(SwsVector *a, double height)
Scale all the coefficients of a so that their sum equals height.
#define SWS_MAX_REDUCE_CUTOFF
Filter kernel cut-off value.
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.
#define SWS_PARAM_DEFAULT
void sws_freeContext(SwsContext *sws)
Free the swscaler context swsContext.
void sws_scaleVec(SwsVector *a, double scalar)
Scale all the coefficients of a by the scalar value.
int sws_setColorspaceDetails(SwsContext *sws, const int inv_table[4], int srcRange, const int table[4], int dstRange, int brightness, int contrast, int saturation)
@ SWS_SCALE_SPLINE
unwindowned natural cubic spline
@ SWS_SCALE_POINT
nearest neighbor (point sampling)
@ SWS_SCALE_LANCZOS
3-tap sinc/sinc
@ SWS_SCALE_BILINEAR
bilinear filtering
@ SWS_SCALE_GAUSSIAN
2-tap gaussian approximation
@ SWS_SCALE_BICUBIC
2-tap cubic BC-spline
@ SWS_SCALE_AREA
area averaging
@ SWS_SCALE_SINC
unwindowed sinc
@ SWS_PRINT_INFO
Emit verbose log of scaling parameters.
@ SWS_SPLINE
unwindowed natural cubic spline
@ SWS_BICUBIC
2-tap cubic B-spline
@ SWS_BICUBLIN
bicubic luma, bilinear chroma
@ SWS_ERROR_DIFFUSION
Set SwsContext.dither instead.
@ SWS_BILINEAR
bilinear filtering
@ SWS_UNSTABLE
Allow/prefer using experimental new code paths.
@ SWS_FULL_CHR_H_INP
Perform full chroma interpolation when downscaling RGB sources.
@ SWS_SINC
unwindowed sinc
@ SWS_LANCZOS
3-tap sinc/sinc
@ SWS_GAUSS
gaussian approximation
@ SWS_FAST_BILINEAR
Scaler selection options.
@ SWS_ACCURATE_RND
Force bit-exact output.
@ SWS_POINT
nearest neighbor
@ SWS_FULL_CHR_H_INT
Perform full chroma upsampling when upscaling to RGB.
void av_opt_set_defaults(void *s)
Set the values of all AVOption fields to their default values.
int av_opt_copy(void *dst, const void *src)
Copy options from src object into dest object.
static av_always_inline void scale(vec_s32 res[4], vec_s16 res_packed[2], const int shift)
const VDPAUPixFmtMap * map
void * ff_sws_jit_alloc(size_t size)
void ff_sws_jit_free(void *ptr, size_t size)
int ff_sws_jit_protect(void *ptr, size_t size)
static int shift(int a, int b)
int(* func)(AVBPrint *dst, const char *in, const char *arg)
Macro definitions for various function/variable attributes.
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_SLOW_GATHER
CPU has slow gathers.
#define AV_CPU_FLAG_MMX
standard MMX
av_cold void ff_frame_pool_uninit(FFFramePool *pool)
Deallocate the frame pool.
#define FF_ALLOC_TYPED_ARRAY(p, nelem)
#define FF_ALLOCZ_TYPED_ARRAY(p, nelem)
#define PPC_ALTIVEC(flags)
static int ff_thread_once(char *control, void(*routine)(void))
#define EXTERNAL_AVX2_FAST(flags)
#define INLINE_MMXEXT(flags)
#define INLINE_MMX(flags)
const AVClass ff_sws_context_class
static av_cold int get_center_offset(SwsInternal *s, int chr_subsample, int pos, int dir)
static SwsVector * sws_getConstVec(double c, int length)
Allocate and return a vector with length coefficients, all with the same value c.
static int handle_0alpha(int *format)
static int handle_xyz(int *format)
static SwsVector * sws_getIdentityVec(void)
Allocate and return a vector with just one coefficient, with value 1.0.
static enum AVPixelFormat alphaless_fmt(enum AVPixelFormat fmt)
static SwsVector * sws_sumVec(SwsVector *a, SwsVector *b)
int ff_shuffle_filter_coefficients(SwsInternal *c, int *filterPos, int filterSize, int16_t *filter, int dstW)
av_cold int ff_sws_init_single_context(SwsContext *sws, SwsFilter *srcFilter, SwsFilter *dstFilter)
static SwsContext * 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 without performing initialization.
static uint16_t * alloc_gamma_tbl(double e)
static void set_cascade_chr_pos(SwsContext *cascade, const SwsContext *sws, int src, int dst)
static const ScaleAlgorithm scale_algorithms[]
static int context_init_threaded(SwsContext *sws, SwsFilter *src_filter, SwsFilter *dst_filter)
static void sws_addVec(SwsVector *a, SwsVector *b)
static int handle_formats(SwsContext *sws)
static double getSplineCoeff(double a, double b, double c, double d, double dist)
static av_cold int initFilter(int16_t **outFilter, int32_t **filterPos, int *outFilterSize, int xInc, int srcW, int dstW, int filterAlign, int one, int scaler, int flags, int cpu_flags, SwsVector *srcFilter, SwsVector *dstFilter, double param[SWS_NUM_SCALER_PARAMS], int srcPos, int dstPos)
static av_cold void init_xyz_tables_once(void)
SwsBackend ff_sws_enabled_backends(const SwsContext *ctx)
static uint16_t xyzgammainv_tab[65536]
static void init_xyz_luts(SwsLuts *luts, enum AVColorTransferCharacteristic trc_in, enum AVColorTransferCharacteristic trc_out)
int ff_sws_thread_exec(void *priv, int(*func)(void *priv, int jobnr, int threadnr, int nb_jobs, int nb_threads), int nb_threads, int nb_jobs)
Helper for dispatching a single function across multiple threads.
static uint16_t xyzgamma_tab[4096]
static int handle_jpeg(int *format)
static void init_xyz_tables(SwsLuts *xyz2rgb, SwsLuts *rgb2xyz)
static void makenan_vec(SwsVector *a)
static double sws_dcVec(SwsVector *a)
static int isnan_vec(SwsVector *a)
static void sws_shiftVec(SwsVector *a, int shift)
static av_cold int get_local_pos(SwsInternal *s, int chr_subsample, int pos, int dir)
static void fill_xyz_matrix(int16_t mat[3][3], const SwsMatrix3x3 *m, double scale)
static uint16_t rgbgammainv_tab[4096]
static double trc_peak(enum AVColorTransferCharacteristic trc)
static int scaler_flag(SwsScaler scaler, int fallback)
int ff_range_add(RangeList *rl, unsigned int start, unsigned int len)
av_cold int ff_sws_fill_st428_tables(SwsInternal *c)
static SwsVector * sws_getShiftedVec(SwsVector *a, int shift)
static 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.
static uint16_t rgbgamma_tab[65536]
static void fill_rgb2yuv_table(SwsInternal *c, const int table[4], int dstRange)
static int range_override_needed(enum AVPixelFormat format)
#define FFSWAP(type, a, b)
void * av_calloc(size_t nmemb, size_t size)
Memory handling functions.
#define sws_isSupportedOutput(x)
#define sws_isSupportedInput(x)
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_YAF16BE
IEEE-754 half precision packed YA, 16 bits gray, 16 bits alpha, 32bpp, 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_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_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_GBRPF16BE
IEEE-754 half precision planer GBR 4:4:4, 48bpp, big-endian.
@ AV_PIX_FMT_GBRPF32BE
IEEE-754 single precision planar GBR 4:4:4, 96bpp, big-endian.
@ AV_PIX_FMT_RGBF32LE
IEEE-754 single precision packed RGB 32:32:32, 96bpp, RGBRGB..., little-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_GBRP10MSBBE
planar GBR 4:4:4 30bpp, lowest bits zero, 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_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
@ AV_PIX_FMT_ARGB
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
@ 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_BGRA
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
@ AV_PIX_FMT_GRAY12BE
Y , 12bpp, big-endian.
@ AV_PIX_FMT_X2BGR10LE
packed BGR 10:10:10, 30bpp, (msb)2X 10B 10G 10R(lsb), little-endian, X=unused/undefined
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
@ AV_PIX_FMT_GRAYF16BE
IEEE-754 half precision Y, 16bpp, big-endian.
@ 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_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_YAF16LE
IEEE-754 half precision packed YA, 16 bits gray, 16 bits alpha, 32bpp, little-endian.
@ AV_PIX_FMT_YUVA420P
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
@ AV_PIX_FMT_YUVA422P10LE
planar YUV 4:2:2 30bpp, (1 Cr & Cb sample per 2x1 Y & A samples, little-endian)
@ AV_PIX_FMT_GBRPF16LE
IEEE-754 half precision planer GBR 4:4:4, 48bpp, 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_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)3R 3G 2B(lsb)
@ AV_PIX_FMT_YAF32BE
IEEE-754 single precision packed YA, 32 bits gray, 32 bits alpha, 64bpp, big-endian.
@ AV_PIX_FMT_GBRAP14BE
planar GBR 4:4:4:4 56bpp, big-endian
@ 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_GBRAP16BE
planar GBRA 4:4:4:4 64bpp, big-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_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_GBRP10MSBLE
planar GBR 4:4:4 30bpp, lowest bits zero, 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_YAF32LE
IEEE-754 single precision packed YA, 32 bits gray, 32 bits alpha, 64bpp, 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_YUVA444P
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A 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_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_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_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_GBRAPF32BE
IEEE-754 single precision planar GBRA 4:4:4:4, 128bpp, big-endian.
@ AV_PIX_FMT_GBRP12MSBLE
planar GBR 4:4:4 36bpp, lowest bits zero, little-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_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_GBRAPF32LE
IEEE-754 single precision planar GBRA 4:4:4:4, 128bpp, little-endian.
@ AV_PIX_FMT_GBRAP14LE
planar GBR 4:4:4:4 56bpp, 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_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_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_GBRAPF16BE
IEEE-754 half precision planar GBRA 4:4:4:4, 64bpp, big-endian.
@ AV_PIX_FMT_GRAYF16LE
IEEE-754 half precision Y, 16bpp, little-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_GBRAP10LE
planar GBR 4:4:4:4 40bpp, 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_GBRAP16LE
planar GBRA 4:4:4:4 64bpp, little-endian
@ AV_PIX_FMT_GBRAPF16LE
IEEE-754 half precision planar GBRA 4:4:4:4, 64bpp, little-endian.
@ 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_RGBAF32BE
IEEE-754 single precision packed RGBA 32:32:32:32, 128bpp, RGBARGBA..., big-endian.
@ AV_PIX_FMT_YA8
8 bits gray, 8 bits alpha
@ 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_YUVJ444P
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
@ 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_RGBF32BE
IEEE-754 single precision packed RGB 32:32:32, 96bpp, RGBRGB..., big-endian.
@ AV_PIX_FMT_RGBAF32LE
IEEE-754 single precision packed RGBA 32:32:32:32, 128bpp, RGBARGBA..., little-endian.
@ 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_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_YUVJ420P
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
@ AV_PIX_FMT_GBRP12MSBBE
planar GBR 4:4:4 36bpp, lowest bits zero, big-endian
#define AV_PIX_FMT_BGR565
#define AV_PIX_FMT_YUV422P16
#define AV_PIX_FMT_BGRA64
#define AV_PIX_FMT_GRAY16
@ AVCOL_PRI_BT709
also ITU-R BT1361 / IEC 61966-2-4 / SMPTE RP 177 Annex B
AVColorTransferCharacteristic
Color Transfer Characteristic.
#define AV_PIX_FMT_GBRP16
#define AV_PIX_FMT_GBRP14
#define AV_PIX_FMT_YUV444P16
#define AV_PIX_FMT_YUV444P10
av_cold void ff_yuv2rgb_init_tables_ppc(SwsInternal *c, const int inv_table[4], int brightness, int contrast, int saturation)
static const uint16_t table[]
void av_refstruct_unref(void *objp)
Decrement the reference count of the underlying object and automatically free the object if there are...
av_cold void ff_sws_rgb2rgb_init(void)
#define FF_ARRAY_ELEMS(a)
int ff_free_filters(SwsInternal *c)
int ff_init_filters(SwsInternal *c)
void avpriv_slicethread_free(AVSliceThread **pctx)
Destroy slice threading context.
int avpriv_slicethread_execute2(AVSliceThread *ctx, int nb_jobs, int execute_main)
Execute slice threading.
int avpriv_slicethread_create2(AVSliceThread **pctx, void *priv, int(*worker_func)(void *priv, int jobnr, int threadnr, int nb_jobs, int nb_threads), int(*main_func)(void *priv), int nb_threads)
Create slice threading context.
struct AVSliceThread AVSliceThread
#define atomic_init(obj, value)
Describe the class of an AVClass context structure.
Struct that contains both white point location and primaries location, providing the complete descrip...
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 log2_chroma_w
Amount to shift the luma width right to find the chroma width.
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
int flag
flag associated to the algorithm
int size_factor
size factor used when initing the filters
const char * description
human-readable description
Main external API structure.
int src_h
Width and height of the source frame.
int dst_format
Destination pixel format.
int gamma_flag
Use gamma correct scaling.
int threads
How many threads to use for processing, or 0 for automatic selection.
SwsScaler scaler
Scaling filter.
int dst_h
Width and height of the destination frame.
SwsAlphaBlend alpha_blend
Alpha blending mode.
double scaler_params[SWS_NUM_SCALER_PARAMS]
int dst_h_chr_pos
Destination horizontal chroma position.
SwsScaler scaler_sub
Scaler used specifically for up/downsampling subsampled (chroma) planes.
int src_w
Deprecated frame property overrides, for the legacy API only.
int src_format
Source pixel format.
int src_v_chr_pos
Source vertical chroma position in luma grid / 256.
int dst_v_chr_pos
Destination vertical chroma position.
SwsDither dither
Dither mode.
int dst_range
Destination is full range.
unsigned flags
Bitmask of SWS_*.
int src_range
Source is full range.
int src_h_chr_pos
Source horizontal chroma position.
double * coeff
pointer to the list of coefficients
int length
number of coefficients in the vector
void ff_sws_init_scale(SwsInternal *c)
int ff_sws_slice_worker(void *priv, int jobnr, int threadnr, int nb_jobs, int nb_threads)
av_cold void ff_sws_init_range_convert(SwsInternal *c)
#define SWS_NUM_SCALER_PARAMS
Extra parameters for fine-tuning certain scalers.
#define SWSINTERNAL_ADDITIONAL_ASM_SIZE
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)
static av_always_inline int is16BPS(enum AVPixelFormat pix_fmt)
#define RETCODE_USE_CASCADE
static av_always_inline int isGray(enum AVPixelFormat pix_fmt)
static SwsInternal * sws_internal(const SwsContext *sws)
void ff_get_unscaled_swscale(SwsInternal *c)
Set c->convert_unscaled to an unscaled converter if one exists for the specific source and destinatio...
int ff_sws_init_altivec_bufs(SwsInternal *c)
void ff_sws_free_altivec_bufs(SwsInternal *c)
static av_always_inline int isALPHA(enum AVPixelFormat pix_fmt)
static av_always_inline int isPlanarRGB(enum AVPixelFormat pix_fmt)
int ff_yuv2rgb_c_init_tables(SwsInternal *c, const int inv_table[4], int fullRange, int brightness, int contrast, int saturation)
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)
void(* filter)(uint8_t *src, ptrdiff_t stride, int qscale)
static const float xyz2rgb[3][3]
static const uint8_t quality[]