23 #define _SVID_SOURCE // needed for MAP_ANONYMOUS
31 #if defined(MAP_ANON) && !defined(MAP_ANONYMOUS)
32 #define MAP_ANONYMOUS MAP_ANON
36 #define WIN32_LEAN_AND_MEAN
40 #include "libavutil/attributes.h"
41 #include "libavutil/avutil.h"
42 #include "libavutil/bswap.h"
43 #include "libavutil/cpu.h"
44 #include "libavutil/intreadwrite.h"
45 #include "libavutil/mathematics.h"
46 #include "libavutil/opt.h"
47 #include "libavutil/pixdesc.h"
67 #define LICENSE_PREFIX "libswscale license: "
71 #define RET 0xC3 // near return opcode for x86
211 return "Unknown format";
218 return ((d * dist + c) * dist + b) * dist +
a;
221 b + 2.0 * c + 3.0 * d,
223 -b - 3.0 * c - 6.0 * d,
228 int *outFilterSize,
int xInc,
int srcW,
229 int dstW,
int filterAlign,
int one,
230 int flags,
int cpu_flags,
232 double param[2],
int is_horizontal)
239 int64_t *filter2 =
NULL;
240 const int64_t fone = 1LL << 54;
248 if (
FFABS(xInc - 0x10000) < 10) {
252 dstW *
sizeof(*filter) * filterSize, fail);
254 for (i = 0; i < dstW; i++) {
255 filter[i * filterSize] = fone;
263 dstW *
sizeof(*filter) * filterSize, fail);
265 xDstInSrc = xInc / 2 - 0x8000;
266 for (i = 0; i < dstW; i++) {
267 int xx = (xDstInSrc - ((filterSize - 1) << 15) + (1 << 15)) >> 16;
269 (*filterPos)[i] = xx;
273 }
else if ((xInc <= (1 << 16) && (flags &
SWS_AREA)) ||
279 dstW *
sizeof(*filter) * filterSize, fail);
281 xDstInSrc = xInc / 2 - 0x8000;
282 for (i = 0; i < dstW; i++) {
283 int xx = (xDstInSrc - ((filterSize - 1) << 15) + (1 << 15)) >> 16;
286 (*filterPos)[i] = xx;
288 for (j = 0; j < filterSize; j++) {
289 int64_t coeff = fone -
FFABS((xx << 16) - xDstInSrc) *
293 filter[i * filterSize + j] = coeff;
304 else if (flags &
SWS_X)
324 filterSize = 1 + sizeFactor;
326 filterSize = 1 + (sizeFactor * srcW + dstW - 1) / dstW;
328 filterSize =
FFMIN(filterSize, srcW - 2);
329 filterSize =
FFMAX(filterSize, 1);
332 dstW *
sizeof(*filter) * filterSize, fail);
334 xDstInSrc = xInc - 0x10000;
335 for (i = 0; i < dstW; i++) {
336 int xx = (xDstInSrc - ((int64_t)(filterSize - 2) << 16)) / (1 << 17);
338 (*filterPos)[i] = xx;
339 for (j = 0; j < filterSize; j++) {
340 int64_t d = (
FFABS(((int64_t)xx << 17) - xDstInSrc)) << 13;
346 floatd = d * (1.0 / (1 << 30));
348 if (flags & SWS_BICUBIC) {
352 if (d >= 1LL << 31) {
355 int64_t dd = (d * d) >> 30;
356 int64_t ddd = (dd * d) >> 30;
359 coeff = (12 * (1 << 24) - 9 * B - 6 * C) * ddd +
360 (-18 * (1 << 24) + 12 * B + 6 * C) * dd +
361 (6 * (1 << 24) - 2 * B) * (1 << 30);
363 coeff = (-B - 6 * C) * ddd +
364 (6 * B + 30 * C) * dd +
365 (-12 * B - 48 * C) * d +
366 (8 * B + 24 * C) * (1 << 30);
368 coeff *= fone >> (30 + 24);
371 else if (flags & SWS_X) {
372 double p = param ? param * 0.01 : 0.3;
373 coeff = d ? sin(d * M_PI) / (d * M_PI) : 1.0;
374 coeff *= pow(2.0, -p * d * d);
377 else if (flags & SWS_X) {
382 c = cos(floatd * M_PI);
389 coeff = (c * 0.5 + 0.5) * fone;
390 }
else if (flags & SWS_AREA) {
391 int64_t d2 = d - (1 << 29);
392 if (d2 * xInc < -(1LL << (29 + 16)))
393 coeff = 1.0 * (1LL << (30 + 16));
394 else if (d2 * xInc < (1LL << (29 + 16)))
395 coeff = -d2 * xInc + (1LL << (29 + 16));
398 coeff *= fone >> (30 + 16);
399 }
else if (flags & SWS_GAUSS) {
401 coeff = (pow(2.0, -p * floatd * floatd)) * fone;
402 }
else if (flags & SWS_SINC) {
403 coeff = (d ? sin(floatd * M_PI) / (floatd * M_PI) : 1.0) * fone;
404 }
else if (flags & SWS_LANCZOS) {
406 coeff = (d ? sin(floatd * M_PI) * sin(floatd * M_PI / p) /
407 (floatd * floatd * M_PI * M_PI / p) : 1.0) * fone;
410 }
else if (flags & SWS_BILINEAR) {
411 coeff = (1 << 30) - d;
415 }
else if (flags & SWS_SPLINE) {
416 double p = -2.196152422706632;
423 filter[i * filterSize + j] = coeff;
426 xDstInSrc += 2 * xInc;
433 assert(filterSize > 0);
434 filter2Size = filterSize;
436 filter2Size += srcFilter->
length - 1;
438 filter2Size += dstFilter->
length - 1;
439 assert(filter2Size > 0);
442 for (i = 0; i < dstW; i++) {
446 for (k = 0; k < srcFilter->
length; k++) {
447 for (j = 0; j < filterSize; j++)
448 filter2[i * filter2Size + k + j] +=
449 srcFilter->
coeff[k] * filter[i * filterSize + j];
452 for (j = 0; j < filterSize; j++)
453 filter2[i * filter2Size + j] = filter[i * filterSize + j];
457 (*filterPos)[i] += (filterSize - 1) / 2 - (filter2Size - 1) / 2;
464 for (i = dstW - 1; i >= 0; i--) {
465 int min = filter2Size;
467 int64_t cutOff = 0.0;
470 for (j = 0; j < filter2Size; j++) {
472 cutOff +=
FFABS(filter2[i * filter2Size]);
479 if (i < dstW - 1 && (*filterPos)[i] >= (*filterPos)[i + 1])
483 for (k = 1; k < filter2Size; k++)
484 filter2[i * filter2Size + k - 1] = filter2[i * filter2Size + k];
485 filter2[i * filter2Size + k - 1] = 0;
491 for (j = filter2Size - 1; j > 0; j--) {
492 cutOff +=
FFABS(filter2[i * filter2Size + j]);
499 if (min > minFilterSize)
505 if (minFilterSize < 5)
511 if (minFilterSize < 3)
517 if (minFilterSize == 1 && filterAlign == 2)
521 assert(minFilterSize > 0);
522 filterSize = (minFilterSize + (filterAlign - 1)) & (~(filterAlign - 1));
523 assert(filterSize > 0);
524 filter =
av_malloc(filterSize * dstW *
sizeof(*filter));
528 *outFilterSize = filterSize;
532 "SwScaler: reducing / aligning filtersize %d -> %d\n",
533 filter2Size, filterSize);
535 for (i = 0; i < dstW; i++) {
538 for (j = 0; j < filterSize; j++) {
539 if (j >= filter2Size)
540 filter[i * filterSize + j] = 0;
542 filter[i * filterSize + j] = filter2[i * filter2Size + j];
544 filter[i * filterSize + j] = 0;
552 for (i = 0; i < dstW; i++) {
554 if ((*filterPos)[i] < 0) {
556 for (j = 1; j < filterSize; j++) {
557 int left =
FFMAX(j + (*filterPos)[i], 0);
558 filter[i * filterSize + left] += filter[i * filterSize + j];
559 filter[i * filterSize + j] = 0;
564 if ((*filterPos)[i] + filterSize > srcW) {
565 int shift = (*filterPos)[i] + filterSize - srcW;
567 for (j = filterSize - 2; j >= 0; j--) {
568 int right =
FFMIN(j + shift, filterSize - 1);
569 filter[i * filterSize + right] += filter[i * filterSize + j];
570 filter[i * filterSize + j] = 0;
572 (*filterPos)[i] = srcW - filterSize;
580 *outFilterSize * (dstW + 3) *
sizeof(int16_t), fail);
583 for (i = 0; i < dstW; i++) {
588 for (j = 0; j < filterSize; j++) {
589 sum += filter[i * filterSize + j];
591 sum = (sum + one / 2) / one;
592 for (j = 0; j < *outFilterSize; j++) {
593 int64_t v = filter[i * filterSize + j] + error;
595 (*outFilter)[i * (*outFilterSize) + j] = intV;
596 error = v - intV * sum;
600 (*filterPos)[dstW + 0] =
601 (*filterPos)[dstW + 1] =
602 (*filterPos)[dstW + 2] = (*filterPos)[dstW - 1];
604 for (i = 0; i < *outFilterSize; i++) {
605 int k = (dstW - 1) * (*outFilterSize) + i;
606 (*outFilter)[k + 1 * (*outFilterSize)] =
607 (*outFilter)[k + 2 * (*outFilterSize)] =
608 (*outFilter)[k + 3 * (*outFilterSize)] = (*outFilter)[k];
619 #if HAVE_MMXEXT_INLINE
620 static av_cold int init_hscaler_mmxext(
int dstW,
int xInc,
uint8_t *filterCode,
649 "movq (%%"REG_d
", %%"REG_a
"), %%mm3 \n\t"
650 "movd (%%"REG_c
", %%"REG_S
"), %%mm0 \n\t"
651 "movd 1(%%"REG_c
", %%"REG_S
"), %%mm1 \n\t"
652 "punpcklbw %%mm7, %%mm1 \n\t"
653 "punpcklbw %%mm7, %%mm0 \n\t"
654 "pshufw $0xFF, %%mm1, %%mm1 \n\t"
656 "pshufw $0xFF, %%mm0, %%mm0 \n\t"
658 "psubw %%mm1, %%mm0 \n\t"
659 "movl 8(%%"REG_b
", %%"REG_a
"), %%esi \n\t"
660 "pmullw %%mm3, %%mm0 \n\t"
661 "psllw $7, %%mm1 \n\t"
662 "paddw %%mm1, %%mm0 \n\t"
664 "movq %%mm0, (%%"REG_D
", %%"REG_a
") \n\t"
666 "add $8, %%"REG_a
" \n\t"
681 :
"=r" (fragmentA),
"=r" (imm8OfPShufW1A),
"=r" (imm8OfPShufW2A),
682 "=r" (fragmentLengthA)
689 "movq (%%"REG_d
", %%"REG_a
"), %%mm3 \n\t"
690 "movd (%%"REG_c
", %%"REG_S
"), %%mm0 \n\t"
691 "punpcklbw %%mm7, %%mm0 \n\t"
692 "pshufw $0xFF, %%mm0, %%mm1 \n\t"
694 "pshufw $0xFF, %%mm0, %%mm0 \n\t"
696 "psubw %%mm1, %%mm0 \n\t"
697 "movl 8(%%"REG_b
", %%"REG_a
"), %%esi \n\t"
698 "pmullw %%mm3, %%mm0 \n\t"
699 "psllw $7, %%mm1 \n\t"
700 "paddw %%mm1, %%mm0 \n\t"
702 "movq %%mm0, (%%"REG_D
", %%"REG_a
") \n\t"
704 "add $8, %%"REG_a
" \n\t"
719 :
"=r" (fragmentB),
"=r" (imm8OfPShufW1B),
"=r" (imm8OfPShufW2B),
720 "=r" (fragmentLengthB)
726 for (i = 0; i < dstW / numSplits; i++) {
731 int b = ((xpos + xInc) >> 16) - xx;
732 int c = ((xpos + xInc * 2) >> 16) - xx;
733 int d = ((xpos + xInc * 3) >> 16) - xx;
734 int inc = (d + 1 < 4);
735 uint8_t *fragment = (d + 1 < 4) ? fragmentB : fragmentA;
736 x86_reg imm8OfPShufW1 = (d + 1 < 4) ? imm8OfPShufW1B : imm8OfPShufW1A;
737 x86_reg imm8OfPShufW2 = (d + 1 < 4) ? imm8OfPShufW2B : imm8OfPShufW2A;
738 x86_reg fragmentLength = (d + 1 < 4) ? fragmentLengthB : fragmentLengthA;
739 int maxShift = 3 - (d + inc);
743 filter[i] = ((xpos & 0xFFFF) ^ 0xFFFF) >> 9;
744 filter[i + 1] = (((xpos + xInc) & 0xFFFF) ^ 0xFFFF) >> 9;
745 filter[i + 2] = (((xpos + xInc * 2) & 0xFFFF) ^ 0xFFFF) >> 9;
746 filter[i + 3] = (((xpos + xInc * 3) & 0xFFFF) ^ 0xFFFF) >> 9;
747 filterPos[i / 2] = xx;
749 memcpy(filterCode + fragmentPos, fragment, fragmentLength);
751 filterCode[fragmentPos + imm8OfPShufW1] = (a + inc) |
755 filterCode[fragmentPos + imm8OfPShufW2] = a | (b << 2) |
759 if (i + 4 - inc >= dstW)
761 else if ((filterPos[i / 2] & 3) <= maxShift)
762 shift = filterPos[i / 2] & 3;
764 if (shift && i >= shift) {
765 filterCode[fragmentPos + imm8OfPShufW1] += 0x55 * shift;
766 filterCode[fragmentPos + imm8OfPShufW2] += 0x55 * shift;
767 filterPos[i / 2] -= shift;
771 fragmentPos += fragmentLength;
774 filterCode[fragmentPos] =
RET;
779 filterPos[((i / 2) + 1) & (~1)] = xpos >> 16;
781 return fragmentPos + 1;
793 int srcRange,
const int table[4],
int dstRange,
794 int brightness,
int contrast,
int saturation)
813 contrast, saturation);
818 contrast, saturation);
823 int *srcRange,
int **table,
int *dstRange,
824 int *brightness,
int *contrast,
int *saturation)
876 int usesVFilter, usesHFilter;
883 int dst_stride =
FFALIGN(dstW *
sizeof(int16_t) + 16, 16);
884 int dst_stride_px = dst_stride >> 1;
885 int flags, cpu_flags;
897 unscaled = (srcW == dstW && srcH == dstH);
927 if (dstW < srcW && dstH < srcH)
929 else if (dstW > srcW && dstH > srcH)
934 }
else if (i & (i - 1)) {
936 "Exactly one scaler algorithm must be chosen\n");
940 if (srcW < 4 || srcH < 1 || dstW < 8 || dstH < 1) {
944 srcW, srcH, dstW, dstH);
949 dstFilter = &dummyFilter;
951 srcFilter = &dummyFilter;
953 c->
lumXInc = (((int64_t)srcW << 16) + (dstW >> 1)) / dstW;
954 c->
lumYInc = (((int64_t)srcH << 16) + (dstH >> 1)) / dstH;
957 c->
vRounder = 4 * 0x0001000100010001ULL;
974 "%s output is not supported with half chroma resolution, switching to full\n",
993 "full chroma interpolation for destination format '%s' not yet implemented\n",
1026 if (unscaled && !usesHFilter && !usesVFilter &&
1033 "using unscaled %s -> %s special converter\n",
1052 (srcW & 15) == 0) ? 1 : 0;
1057 "output width is not a multiple of 32 -> no MMXEXT scaler\n");
1074 if (flags & SWS_FAST_BILINEAR) {
1081 c->
lumXInc = ((int64_t)(srcW - 2) << 16) / (dstW - 2) - 20;
1086 #define USE_MMAP (HAVE_MMAP && HAVE_MPROTECT && defined MAP_ANONYMOUS)
1090 #if HAVE_MMXEXT_INLINE
1100 PROT_READ | PROT_WRITE,
1101 MAP_PRIVATE | MAP_ANONYMOUS,
1104 PROT_READ | PROT_WRITE,
1105 MAP_PRIVATE | MAP_ANONYMOUS,
1107 #elif HAVE_VIRTUALALLOC
1111 PAGE_EXECUTE_READWRITE);
1115 PAGE_EXECUTE_READWRITE);
1140 const int filterAlign =
X86_MMX(cpu_flags) ? 4 :
1145 srcW, dstW, filterAlign, 1 << 14,
1147 cpu_flags, srcFilter->
lumH, dstFilter->
lumH,
1153 (flags & SWS_BICUBLIN) ? (flags |
SWS_BILINEAR) : flags,
1154 cpu_flags, srcFilter->
chrH, dstFilter->
chrH,
1162 const int filterAlign =
X86_MMX(cpu_flags) ? 2 :
1166 c->
lumYInc, srcH, dstH, filterAlign, (1 << 12),
1168 cpu_flags, srcFilter->
lumV, dstFilter->
lumV,
1173 filterAlign, (1 << 12),
1174 (flags & SWS_BICUBLIN) ? (flags |
SWS_BILINEAR) : flags,
1175 cpu_flags, srcFilter->
chrV, dstFilter->
chrV,
1185 short *p = (
short *)&c->vYCoeffsBank[i];
1186 for (j = 0; j < 8; j++)
1192 short *p = (
short *)&c->vCCoeffsBank[i];
1193 for (j = 0; j < 8; j++)
1202 for (i = 0; i < dstH; i++) {
1203 int chrI = (int64_t)i * c->
chrDstH / dstH;
1230 dst_stride + 16, fail);
1238 dst_stride * 2 + 32, fail);
1246 dst_stride + 16, fail);
1252 memset(c->
chrUPixBuf[i], 64, dst_stride * 2 + 1);
1257 if (flags & SWS_FAST_BILINEAR)
1263 else if (flags &
SWS_X)
1307 "lum srcW=%d srcH=%d dstW=%d dstH=%d xInc=%d yInc=%d\n",
1310 "chr srcW=%d srcH=%d dstW=%d dstH=%d xInc=%d yInc=%d\n",
1324 SwsFilter *dstFilter,
const double *param)
1342 c->
param[0] = param[0];
1343 c->
param[1] = param[1];
1358 float lumaSharpen,
float chromaSharpen,
1359 float chromaHShift,
float chromaVShift,
1366 if (lumaGBlur != 0.0) {
1374 if (chromaGBlur != 0.0) {
1382 if (chromaSharpen != 0.0) {
1391 if (lumaSharpen != 0.0) {
1400 if (chromaHShift != 0.0)
1403 if (chromaVShift != 0.0)
1433 const int length = (int)(variance * quality + 0.5) | 1;
1435 double middle = (length - 1) * 0.5;
1441 for (i = 0; i < length; i++) {
1442 double dist = i - middle;
1443 vec->
coeff[i] = exp(-dist * dist / (2 * variance * variance)) /
1444 sqrt(2 * variance * M_PI);
1460 for (i = 0; i < length; i++)
1476 for (i = 0; i < a->
length; i++)
1486 for (i = 0; i < a->
length; i++)
1487 a->
coeff[i] *= scalar;
1504 for (i = 0; i < a->
length; i++) {
1505 for (j = 0; j < b->
length; j++) {
1522 for (i = 0; i < a->
length; i++)
1539 for (i = 0; i < a->
length; i++)
1557 for (i = 0; i < a->
length; i++) {
1558 vec->
coeff[i + (length - 1) / 2 -
1609 for (i = 0; i < a->
length; i++)
1622 for (i = 0; i < a->
length; i++)
1623 if (a->
coeff[i] > max)
1626 for (i = 0; i < a->
length; i++)
1627 if (a->
coeff[i] < min)
1632 for (i = 0; i < a->
length; i++) {
1633 int x = (int)((a->
coeff[i] - min) * 60.0 / range + 0.5);
1634 av_log(log_ctx, log_level,
"%1.3f ", a->
coeff[i]);
1636 av_log(log_ctx, log_level,
" ");
1637 av_log(log_ctx, log_level,
"|\n");
1711 #elif HAVE_VIRTUALALLOC
1736 const double *
param)
1742 param = default_param;
1745 (context->
srcW != srcW ||
1746 context->
srcH != srcH ||
1748 context->
dstW != dstW ||
1749 context->
dstH != dstH ||
1751 context->
flags != flags ||
1752 context->
param[0] != param[0] ||
1753 context->
param[1] != param[1])) {
1770 context->
param[0] = param[0];
1771 context->
param[1] = param[1];
1775 context->
dstRange, 0, 1 << 16, 1 << 16);
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
int16_t ** alpPixBuf
Ring buffer for scaled horizontal alpha plane lines to be fed to the vertical scaler.
planar GBR 4:4:4 48bpp, big-endian
int sws_isSupportedOutput(enum AVPixelFormat pix_fmt)
Return a positive value if pix_fmt is a supported output format, 0 otherwise.
static const FormatEntry format_entries[AV_PIX_FMT_NB]
planar YUV 4:4:4 36bpp, (1 Cr & Cb sample per 1x1 Y & A samples), little-endian
ptrdiff_t uv_off_px
offset (in pixels) between u and v planes
packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), little-endian
SwsVector * sws_getConstVec(double c, int length)
Allocate and return a vector with length coefficients, all with the same value c. ...
static SwsVector * sws_sumVec(SwsVector *a, SwsVector *b)
av_cold void ff_yuv2rgb_init_tables_ppc(SwsContext *c, const int inv_table[4], int brightness, int contrast, int saturation)
#define SWS_SRC_V_CHR_DROP_MASK
int chrSrcH
Height of source chroma planes.
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
static av_always_inline int isPlanarRGB(enum AVPixelFormat pix_fmt)
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.
16bit gray, 16bit alpha (big-endian)
uint8_t * chrMmxextFilterCode
Runtime-generated MMXEXT horizontal fast bilinear scaler code for chroma planes.
planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
const char * sws_format_name(enum AVPixelFormat format)
uint8_t * lumMmxextFilterCode
Runtime-generated MMXEXT horizontal fast bilinear scaler code for luma/alpha planes.
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.
packed RGB 8:8:8, 24bpp, RGBRGB...
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
int sws_getColorspaceDetails(struct SwsContext *c, int **inv_table, int *srcRange, int **table, int *dstRange, int *brightness, int *contrast, int *saturation)
planar YUV 4:2:0 22.5bpp, (1 Cr & Cb sample per 2x2 Y & A samples), big-endian
packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr
void av_opt_set_defaults(void *s)
Set the values of all AVOption fields to their default values.
int vChrDrop
Binary logarithm of extra vertical subsampling factor in source image chroma planes specified by user...
int ff_yuv2rgb_c_init_tables(SwsContext *c, const int inv_table[4], int fullRange, int brightness, int contrast, int saturation)
planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
static double getSplineCoeff(double a, double b, double c, double d, double dist)
int dstFormatBpp
Number of bits per pixel of the destination pixel format.
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
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.
void av_log(void *avcl, int level, const char *fmt,...) av_printf_format(3
Send the specified message to the log if the level is less than or equal to the current av_log_level...
static int handle_jpeg(enum AVPixelFormat *format)
int sws_isSupportedEndiannessConversion(enum AVPixelFormat pix_fmt)
planar YUV 4:2:0, 24bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
#define SWS_SRC_V_CHR_DROP_SHIFT
planar YUV 4:4:4 40bpp, (1 Cr & Cb sample per 1x1 Y & A samples, little-endian)
void sws_subVec(SwsVector *a, SwsVector *b)
packed BGR 5:6:5, 16bpp, (msb) 5B 6G 5R(lsb), big-endian
planar GBR 4:4:4 48bpp, little-endian
int srcRange
0 = MPG YUV range, 1 = JPG YUV range (source image).
planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
packed RGB 3:3:2, 8bpp, (msb)2B 3G 3R(lsb)
void av_freep(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
planar YUV 4:2:0, 15bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
int srcH
Height of source luma/alpha planes.
packed YUV 4:2:2, 16bpp, Y0 Cr Y1 Cb
packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as big...
16bit gray, 16bit alpha (little-endian)
const int32_t ff_yuv2rgb_coeffs[8][4]
int chrDstVSubSample
Binary logarithm of vertical subsampling factor between luma/alpha and chroma planes in destination i...
int length
number of coefficients in the vector
planar YUV 4:4:4, 27bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
SwsVector * sws_getGaussianVec(double variance, double quality)
Return a normalized Gaussian curve used to filter stuff quality = 3 is high quality, lower is lower quality.
int vChrFilterSize
Vertical filter size for chroma pixels.
SwsVector * sws_getIdentityVec(void)
Allocate and return a vector with just one coefficient, with value 1.0.
int16_t ** lumPixBuf
Ring buffer for scaled horizontal luma plane lines to be fed to the vertical scaler.
void sws_addVec(SwsVector *a, SwsVector *b)
#define SWS_FULL_CHR_H_INT
planar YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
#define SWS_FAST_BILINEAR
planar YUV 4:2:0, 13.5bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
packed RGBA 16:16:16:16, 64bpp, 16B, 16G, 16R, 16A, the 2-byte value for each R/G/B/A component is st...
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_cold int sws_init_context(SwsContext *c, SwsFilter *srcFilter, SwsFilter *dstFilter)
Initialize the swscaler context sws_context.
#define AV_LOG_VERBOSE
Detailed information.
packed RGB 5:5:5, 16bpp, (msb)1A 5R 5G 5B(lsb), big-endian, most significant bit to 0 ...
packed BGR 5:5:5, 16bpp, (msb)1A 5B 5G 5R(lsb), little-endian, most significant bit to 1 ...
#define ROUNDED_DIV(a, b)
enum AVPixelFormat dstFormat
Destination pixel format.
int av_get_cpu_flags(void)
Return the flags which specify extensions supported by the CPU.
int chrSrcHSubSample
Binary logarithm of horizontal subsampling factor between luma/alpha and chroma planes in source imag...
static av_always_inline int isYUV(enum AVPixelFormat pix_fmt)
static SwsVector * sws_getShiftedVec(SwsVector *a, int shift)
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
int32_t * vChrFilterPos
Array of vertical filter starting positions for each dst[i] for chroma planes.
int dstH
Height of destination luma/alpha planes.
SwsVector * sws_cloneVec(SwsVector *a)
Allocate and return a clone of the vector a, that is a vector with the same coefficients as a...
packed RGB 1:2:1, 8bpp, (msb)1B 2G 1R(lsb)
packed RGBA 16:16:16:16, 64bpp, 16R, 16G, 16B, 16A, the 2-byte value for each R/G/B/A component is st...
uint16_t depth_minus1
Number of bits in the component minus 1.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
packed YUV 4:1:1, 12bpp, Cb Y0 Y1 Cr Y2 Y3
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
planar YUV 4:2:2 30bpp, (1 Cr & Cb sample per 2x1 Y & A samples, little-endian)
int16_t ** chrVPixBuf
Ring buffer for scaled horizontal chroma plane lines to be fed to the vertical scaler.
packed RGB 1:2:1 bitstream, 4bpp, (msb)1B 2G 1R(lsb), a byte contains two pixels, the first pixel in ...
int32_t * hChrFilterPos
Array of horizontal filter starting positions for each dst[i] for chroma planes.
int hLumFilterSize
Horizontal filter size for luma/alpha pixels.
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
SwsFunc ff_getSwsFunc(SwsContext *c)
Return function pointer to fastest main scaler path function depending on architecture and available ...
#define SWS_MAX_REDUCE_CUTOFF
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
planar YUV 4:2:0, 24bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
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.
int vChrBufSize
Number of vertical chroma lines allocated in the ring buffer.
av_cold void sws_rgb2rgb_init(void)
planar GBR 4:4:4 30bpp, little-endian
enum AVPixelFormat av_pix_fmt_swap_endianness(enum AVPixelFormat pix_fmt)
Utility function to swap the endianness of a pixel format.
AVPixelFormat
Pixel format.
void sws_scaleVec(SwsVector *a, double scalar)
Scale all the coefficients of a by the scalar value.
int chrDstW
Width of destination chroma planes.
void sws_normalizeVec(SwsVector *a, double height)
Scale all the coefficients of a so that their sum equals height.
int av_get_bits_per_pixel(const AVPixFmtDescriptor *pixdesc)
Return the number of bits per pixel used by the pixel format described by pixdesc.
int32_t * hLumFilterPos
Array of horizontal filter starting positions for each dst[i] for luma/alpha planes.
void sws_freeFilter(SwsFilter *filter)
int hChrFilterSize
Horizontal filter size for chroma pixels.
planar YUV 4:4:4 64bpp, (1 Cr & Cb sample per 1x1 Y & A samples, big-endian)
static void filter(MpegAudioContext *s, int ch, const short *samples, int incr)
planar YUV 4:4:4, 27bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
ptrdiff_t uv_off_byte
offset (in bytes) between u and v planes
int dstRange
0 = MPG YUV range, 1 = JPG YUV range (destination image).
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
planar YUV 4:2:0 40bpp, (1 Cr & Cb sample per 2x2 Y & A samples, big-endian)
external api for the swscale stuff
planar YUV 4:2:0 22.5bpp, (1 Cr & Cb sample per 2x2 Y & A samples), little-endian ...
uint8_t * formatConvBuffer
int vLumBufSize
Number of vertical luma/alpha lines allocated in the ring buffer.
int16_t ** chrUPixBuf
Ring buffer for scaled horizontal chroma plane lines to be fed to the vertical scaler.
void * av_malloc(size_t size) av_malloc_attrib 1(1)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
planar YUV 4:2:0 25bpp, (1 Cr & Cb sample per 2x2 Y & A samples, big-endian)
packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as lit...
SwsContext * sws_alloc_context(void)
Allocate an empty SwsContext.
planar YUV 4:2:0 25bpp, (1 Cr & Cb sample per 2x2 Y & A samples, little-endian)
void sws_freeContext(SwsContext *c)
Free the swscaler context swsContext.
planar YUV 4:2:2 48bpp, (1 Cr & Cb sample per 2x1 Y & A samples, big-endian)
packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1
packed RGB 5:5:5, 16bpp, (msb)1A 5R 5G 5B(lsb), little-endian, most significant bit to 0 ...
planar GBR 4:4:4 30bpp, big-endian
#define INLINE_MMX(flags)
enum AVPixelFormat pix_fmt
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...
unsigned swscale_version(void)
planar YUV 4:4:4 64bpp, (1 Cr & Cb sample per 1x1 Y & A samples, little-endian)
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)
int srcColorspaceTable[4]
int dstW
Width of destination luma/alpha planes.
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
packed RGB 1:2:1, 8bpp, (msb)1R 2G 1B(lsb)
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
8 bit with PIX_FMT_RGB32 palette
int32_t * vLumFilterPos
Array of vertical filter starting positions for each dst[i] for luma/alpha planes.
packed BGR 4:4:4, 16bpp, (msb)4A 4B 4G 4R(lsb), big-endian, most significant bits to 1 ...
#define AV_LOG_INFO
Standard information.
int dstColorspaceTable[4]
const AVClass * av_class
info on struct for av_log
number of pixel formats, DO NOT USE THIS if you want to link with shared libav* because the number of...
SwsVector * sws_allocVec(int length)
Allocate and return an uninitialized vector with length coefficients.
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
void sws_freeVec(SwsVector *a)
int chrDstH
Height of destination chroma planes.
packed RGB 8:8:8, 24bpp, BGRBGR...
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV422P and setting color_...
planar YUV 4:2:2, 18bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
packed RGBA 16:16:16:16, 64bpp, 16B, 16G, 16R, 16A, the 2-byte value for each R/G/B/A component is st...
const char * swscale_license(void)
Return the libswscale license.
static void getSubSampleFactors(int *h, int *v, enum AVPixelFormat format)
static SwsVector * sws_diffVec(SwsVector *a, SwsVector *b)
void sws_shiftVec(SwsVector *a, int shift)
int lumMmxextFilterCodeSize
Runtime-generated MMXEXT horizontal fast bilinear scaler code size for luma/alpha planes...
Describe the class of an AVClass context structure.
const char * swscale_configuration(void)
Return the libswscale build-time configuration.
int vLumFilterSize
Vertical filter size for luma/alpha pixels.
planar YUV 4:2:0 40bpp, (1 Cr & Cb sample per 2x2 Y & A samples, little-endian)
int chrMmxextFilterCodeSize
Runtime-generated MMXEXT horizontal fast bilinear scaler code size for chroma planes.
planar YUV 4:2:0, 13.5bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
packed RGB 3:3:2, 8bpp, (msb)2R 3G 3B(lsb)
int16_t * vChrFilter
Array of vertical filter coefficients for chroma planes.
planar YUV 4:4:4 40bpp, (1 Cr & Cb sample per 1x1 Y & A samples, big-endian)
Y , 1bpp, 0 is white, 1 is black, in each byte pixels are ordered from the msb to the lsb...
packed RGB 1:2:1 bitstream, 4bpp, (msb)1R 2G 1B(lsb), a byte contains two pixels, the first pixel in ...
#define LIBSWSCALE_VERSION_INT
packed RGBA 16:16:16:16, 64bpp, 16R, 16G, 16B, 16A, the 2-byte value for each R/G/B/A component is st...
int16_t * hLumFilter
Array of horizontal filter coefficients for luma/alpha planes.
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV444P and setting color_...
#define INLINE_AMD3DNOW(flags)
planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (firs...
planar YUV 4:2:2 48bpp, (1 Cr & Cb sample per 2x1 Y & A samples, little-endian)
planar YUV 4:2:0, 15bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of PIX_FMT_YUV440P and setting color_range ...
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
packed BGR 5:5:5, 16bpp, (msb)1A 5B 5G 5R(lsb), big-endian, most significant bit to 1 ...
packed RGB 4:4:4, 16bpp, (msb)4A 4R 4G 4B(lsb), big-endian, most significant bits to 0 ...
planar YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
void sws_convVec(SwsVector *a, SwsVector *b)
const AVClass sws_context_class
static double sws_dcVec(SwsVector *a)
double param[2]
Input parameters for scaling algorithms that need them.
double * coeff
pointer to the list of coefficients
planar YUV 4:2:2 27bpp, (1 Cr & Cb sample per 2x1 Y & A samples), little-endian
planar YUV 4:2:2, 32bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
#define FF_ALLOC_OR_GOTO(ctx, p, size, label)
planar YUV 4:4:4 36bpp, (1 Cr & Cb sample per 1x1 Y & A samples), big-endian
planar YUV 4:2:2, 32bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
enum AVPixelFormat srcFormat
Source pixel format.
packed RGB 4:4:4, 16bpp, (msb)4A 4R 4G 4B(lsb), little-endian, most significant bits to 0 ...
packed RGB 16:16:16, 48bpp, 16B, 16G, 16R, the 2-byte value for each R/G/B component is stored as lit...
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
#define SWS_PARAM_DEFAULT
packed BGR 5:6:5, 16bpp, (msb) 5B 6G 5R(lsb), little-endian
planar GBR 4:4:4 27bpp, little-endian
#define SWS_FULL_CHR_H_INP
SwsFunc swscale
Note that src, dst, srcStride, dstStride will be copied in the sws_scale() wrapper so they can be fre...
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
Y , 16bpp, little-endian.
planar YUV 4:2:2 30bpp, (1 Cr & Cb sample per 2x1 Y & A samples, big-endian)
#define INLINE_MMXEXT(flags)
int srcFormatBpp
Number of bits per pixel of the source pixel format.
uint8_t is_supported_endianness
packed BGR 4:4:4, 16bpp, (msb)4A 4B 4G 4R(lsb), little-endian, most significant bits to 1 ...
#define AV_PIX_FMT_BGR565
int sws_isSupportedInput(enum AVPixelFormat pix_fmt)
Return a positive value if pix_fmt is a supported input format, 0 otherwise.
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 is_horizontal)
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV420P and setting color_...
int16_t * vLumFilter
Array of vertical filter coefficients for luma/alpha planes.
packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), big-endian
int16_t * hChrFilter
Array of horizontal filter coefficients for chroma planes.
SwsFilter * sws_getDefaultFilter(float lumaGBlur, float chromaGBlur, float lumaSharpen, float chromaSharpen, float chromaHShift, float chromaVShift, int verbose)
planar YUV 4:2:2, 18bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
Y , 1bpp, 0 is black, 1 is white, in each byte pixels are ordered from the msb to the lsb...
packed RGB 16:16:16, 48bpp, 16B, 16G, 16R, the 2-byte value for each R/G/B component is stored as big...
planar GBR 4:4:4 27bpp, big-endian
int chrDstHSubSample
Binary logarithm of horizontal subsampling factor between luma/alpha and chroma planes in destination...
int chrSrcW
Width of source chroma planes.
void ff_get_unscaled_swscale(SwsContext *c)
Set c->swscale to an unscaled converter if one exists for the specific source and destination formats...
int srcW
Width of source luma/alpha planes.
int chrSrcVSubSample
Binary logarithm of vertical subsampling factor between luma/alpha and chroma planes in source image...
int flags
Flags passed by the user to select scaler algorithm, optimizations, subsampling, etc...
planar YUV 4:2:2 27bpp, (1 Cr & Cb sample per 2x1 Y & A samples), big-endian
void(* rgb15to16)(const uint8_t *src, uint8_t *dst, int src_size)
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
#define PPC_ALTIVEC(flags)
#define FF_ALLOCZ_OR_GOTO(ctx, p, size, label)
as above, but U and V bytes are swapped
static SwsVector * sws_getConvVec(SwsVector *a, SwsVector *b)
void * av_mallocz(size_t size) av_malloc_attrib 1(1)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
#define AV_PIX_FMT_BGR555