21 #define _SVID_SOURCE //needed for MAP_ANONYMOUS
30 #if defined(MAP_ANON) && !defined(MAP_ANONYMOUS)
31 #define MAP_ANONYMOUS MAP_ANON
35 #define WIN32_LEAN_AND_MEAN
62 #define LICENSE_PREFIX "libswscale license: "
66 #define RET 0xC3 //near return opcode for x86
170 return "Unknown format";
175 if (dist<=1.0)
return ((d*dist + c)*dist + b)*dist +
a;
183 static int initFilter(int16_t **outFilter, int32_t **filterPos,
int *outFilterSize,
int xInc,
184 int srcW,
int dstW,
int filterAlign,
int one,
int flags,
int cpu_flags,
192 int64_t *filter2=
NULL;
193 const int64_t fone= 1LL<<54;
201 if (
FFABS(xInc - 0x10000) <10) {
206 for (i=0; i<dstW; i++) {
207 filter[i*filterSize]= fone;
217 xDstInSrc= xInc/2 - 0x8000;
218 for (i=0; i<dstW; i++) {
219 int xx= (xDstInSrc - ((filterSize-1)<<15) + (1<<15))>>16;
231 xDstInSrc= xInc/2 - 0x8000;
232 for (i=0; i<dstW; i++) {
233 int xx= (xDstInSrc - ((filterSize-1)<<15) + (1<<15))>>16;
238 for (j=0; j<filterSize; j++) {
239 int64_t coeff= fone -
FFABS((xx<<16) - xDstInSrc)*(fone>>16);
240 if (coeff<0) coeff=0;
241 filter[i*filterSize + j]= coeff;
251 else if (flags&
SWS_X) sizeFactor= 8;
252 else if (flags&
SWS_AREA) sizeFactor= 1;
255 else if (flags&
SWS_SINC) sizeFactor= 20;
263 if (xInc <= 1<<16) filterSize= 1 + sizeFactor;
264 else filterSize= 1 + (sizeFactor*srcW + dstW - 1)/ dstW;
266 filterSize = av_clip(filterSize, 1, srcW - 2);
270 xDstInSrc= xInc - 0x10000;
271 for (i=0; i<dstW; i++) {
272 int xx = (xDstInSrc - ((int64_t)(filterSize - 2) << 16)) / (1 << 17);
275 for (j=0; j<filterSize; j++) {
276 int64_t d= ((int64_t)
FFABS((xx<<17) - xDstInSrc))<<13;
282 floatd= d * (1.0/(1<<30));
284 if (flags & SWS_BICUBIC) {
291 int64_t dd = (d * d) >> 30;
292 int64_t ddd = (dd * d) >> 30;
295 coeff = (12*(1<<24)-9*B-6*C)*ddd + (-18*(1<<24)+12*B+6*C)*dd + (6*(1<<24)-2*B)*(1<<30);
297 coeff = (-B-6*C)*ddd + (6*B+30*C)*dd + (-12*B-48*C)*d + (8*B+24*C)*(1<<30);
299 coeff *= fone>>(30+24);
306 else if (flags & SWS_X) {
311 c = cos(floatd*
M_PI);
314 if (c<0.0) c= -pow(-c, A);
316 coeff= (c*0.5 + 0.5)*fone;
317 }
else if (flags & SWS_AREA) {
318 int64_t d2= d - (1<<29);
319 if (d2*xInc < -(1LL<<(29+16))) coeff= 1.0 * (1LL<<(30+16));
320 else if (d2*xInc < (1LL<<(29+16))) coeff= -d2*xInc + (1LL<<(29+16));
322 coeff *= fone>>(30+16);
323 }
else if (flags & SWS_GAUSS) {
325 coeff = (pow(2.0, - p*floatd*floatd))*fone;
326 }
else if (flags & SWS_SINC) {
327 coeff = (d ? sin(floatd*
M_PI)/(floatd*
M_PI) : 1.0)*fone;
328 }
else if (flags & SWS_LANCZOS) {
330 coeff = (d ? sin(floatd*
M_PI)*sin(floatd*M_PI/p)/(floatd*floatd*M_PI*M_PI/p) : 1.0)*fone;
331 if (floatd>p) coeff=0;
332 }
else if (flags & SWS_BILINEAR) {
334 if (coeff<0) coeff=0;
336 }
else if (flags & SWS_SPLINE) {
337 double p=-2.196152422706632;
344 filter[i*filterSize + j]= coeff;
354 assert(filterSize>0);
355 filter2Size= filterSize;
356 if (srcFilter) filter2Size+= srcFilter->
length - 1;
357 if (dstFilter) filter2Size+= dstFilter->
length - 1;
358 assert(filter2Size>0);
361 for (i=0; i<dstW; i++) {
365 for (k=0; k<srcFilter->
length; k++) {
366 for (j=0; j<filterSize; j++)
367 filter2[i*filter2Size + k + j] += srcFilter->
coeff[k]*filter[i*filterSize + j];
370 for (j=0; j<filterSize; j++)
371 filter2[i*filter2Size + j]= filter[i*filterSize + j];
375 (*filterPos)[i]+= (filterSize-1)/2 - (filter2Size-1)/2;
382 for (i=dstW-1; i>=0; i--) {
383 int min= filter2Size;
388 for (j=0; j<filter2Size; j++) {
390 cutOff +=
FFABS(filter2[i*filter2Size]);
395 if (i<dstW-1 && (*filterPos)[i] >= (*filterPos)[i+1])
break;
398 for (k=1; k<filter2Size; k++)
399 filter2[i*filter2Size + k - 1]= filter2[i*filter2Size + k];
400 filter2[i*filter2Size + k - 1]= 0;
406 for (j=filter2Size-1; j>0; j--) {
407 cutOff +=
FFABS(filter2[i*filter2Size + j]);
413 if (min>minFilterSize) minFilterSize=
min;
419 if (minFilterSize < 5)
427 if (minFilterSize < 3)
433 if (minFilterSize == 1 && filterAlign == 2)
437 assert(minFilterSize > 0);
438 filterSize= (minFilterSize +(filterAlign-1)) & (~(filterAlign-1));
439 assert(filterSize > 0);
440 filter=
av_malloc(filterSize*dstW*
sizeof(*filter));
443 *outFilterSize= filterSize;
448 for (i=0; i<dstW; i++) {
451 for (j=0; j<filterSize; j++) {
452 if (j>=filter2Size) filter[i*filterSize + j]= 0;
453 else filter[i*filterSize + j]= filter2[i*filter2Size + j];
455 filter[i*filterSize + j]= 0;
463 for (i = 0; i < dstW; i++) {
465 if ((*filterPos)[i] < 0) {
467 for (j = 1; j < filterSize; j++) {
468 int left =
FFMAX(j + (*filterPos)[i], 0);
469 filter[i * filterSize + left] += filter[i * filterSize + j];
470 filter[i * filterSize + j ] = 0;
475 if ((*filterPos)[i] + filterSize > srcW) {
476 int shift = (*filterPos)[i] + filterSize - srcW;
478 for (j = filterSize - 2; j >= 0; j--) {
479 int right =
FFMIN(j + shift, filterSize - 1);
480 filter[i * filterSize + right] += filter[i * filterSize + j];
481 filter[i * filterSize + j ] = 0;
483 (*filterPos)[i] = srcW - filterSize;
493 for (i=0; i<dstW; i++) {
498 for (j=0; j<filterSize; j++) {
499 sum+= filter[i*filterSize + j];
501 sum= (sum + one/2)/ one;
502 for (j=0; j<*outFilterSize; j++) {
503 int64_t
v= filter[i*filterSize + j] + error;
505 (*outFilter)[i*(*outFilterSize) + j]= intV;
510 (*filterPos)[dstW+0] =
511 (*filterPos)[dstW+1] =
512 (*filterPos)[dstW+2] = (*filterPos)[dstW-1];
513 for (i=0; i<*outFilterSize; i++) {
514 int k= (dstW - 1) * (*outFilterSize) + i;
515 (*outFilter)[k + 1 * (*outFilterSize)] =
516 (*outFilter)[k + 2 * (*outFilterSize)] =
517 (*outFilter)[k + 3 * (*outFilterSize)] = (*outFilter)[k];
528 static int initMMX2HScaler(
int dstW,
int xInc, uint8_t *filterCode, int16_t *
filter, int32_t *filterPos,
int numSplits)
556 "movq (%%"REG_d
", %%"REG_a
"), %%mm3 \n\t"
557 "movd (%%"REG_c
", %%"REG_S
"), %%mm0 \n\t"
558 "movd 1(%%"REG_c
", %%"REG_S
"), %%mm1 \n\t"
559 "punpcklbw %%mm7, %%mm1 \n\t"
560 "punpcklbw %%mm7, %%mm0 \n\t"
561 "pshufw $0xFF, %%mm1, %%mm1 \n\t"
563 "pshufw $0xFF, %%mm0, %%mm0 \n\t"
565 "psubw %%mm1, %%mm0 \n\t"
566 "movl 8(%%"REG_b
", %%"REG_a
"), %%esi \n\t"
567 "pmullw %%mm3, %%mm0 \n\t"
568 "psllw $7, %%mm1 \n\t"
569 "paddw %%mm1, %%mm0 \n\t"
571 "movq %%mm0, (%%"REG_D
", %%"REG_a
") \n\t"
573 "add $8, %%"REG_a
" \n\t"
588 :
"=r" (fragmentA),
"=r" (imm8OfPShufW1A),
"=r" (imm8OfPShufW2A),
589 "=r" (fragmentLengthA)
596 "movq (%%"REG_d
", %%"REG_a
"), %%mm3 \n\t"
597 "movd (%%"REG_c
", %%"REG_S
"), %%mm0 \n\t"
598 "punpcklbw %%mm7, %%mm0 \n\t"
599 "pshufw $0xFF, %%mm0, %%mm1 \n\t"
601 "pshufw $0xFF, %%mm0, %%mm0 \n\t"
603 "psubw %%mm1, %%mm0 \n\t"
604 "movl 8(%%"REG_b
", %%"REG_a
"), %%esi \n\t"
605 "pmullw %%mm3, %%mm0 \n\t"
606 "psllw $7, %%mm1 \n\t"
607 "paddw %%mm1, %%mm0 \n\t"
609 "movq %%mm0, (%%"REG_D
", %%"REG_a
") \n\t"
611 "add $8, %%"REG_a
" \n\t"
626 :
"=r" (fragmentB),
"=r" (imm8OfPShufW1B),
"=r" (imm8OfPShufW2B),
627 "=r" (fragmentLengthB)
633 for (i=0; i<dstW/numSplits; i++) {
638 int b=((xpos+xInc)>>16) - xx;
639 int c=((xpos+xInc*2)>>16) - xx;
640 int d=((xpos+xInc*3)>>16) - xx;
642 uint8_t *fragment = (d+1<4) ? fragmentB : fragmentA;
643 x86_reg imm8OfPShufW1 = (d+1<4) ? imm8OfPShufW1B : imm8OfPShufW1A;
644 x86_reg imm8OfPShufW2 = (d+1<4) ? imm8OfPShufW2B : imm8OfPShufW2A;
645 x86_reg fragmentLength = (d+1<4) ? fragmentLengthB : fragmentLengthA;
646 int maxShift= 3-(d+inc);
650 filter[i ] = (( xpos & 0xFFFF) ^ 0xFFFF)>>9;
651 filter[i+1] = (((xpos+xInc ) & 0xFFFF) ^ 0xFFFF)>>9;
652 filter[i+2] = (((xpos+xInc*2) & 0xFFFF) ^ 0xFFFF)>>9;
653 filter[i+3] = (((xpos+xInc*3) & 0xFFFF) ^ 0xFFFF)>>9;
656 memcpy(filterCode + fragmentPos, fragment, fragmentLength);
658 filterCode[fragmentPos + imm8OfPShufW1]=
659 (a+inc) | ((b+inc)<<2) | ((c+inc)<<4) | ((d+inc)<<6);
660 filterCode[fragmentPos + imm8OfPShufW2]=
661 a | (b<<2) | (c<<4) | (d<<6);
663 if (i+4-inc>=dstW) shift=maxShift;
664 else if ((filterPos[i/2]&3) <= maxShift) shift=filterPos[i/2]&3;
666 if (shift && i>=shift) {
667 filterCode[fragmentPos + imm8OfPShufW1]+= 0x55*shift;
668 filterCode[fragmentPos + imm8OfPShufW2]+= 0x55*shift;
669 filterPos[i/2]-=shift;
673 fragmentPos+= fragmentLength;
676 filterCode[fragmentPos]=
RET;
681 filterPos[((i/2)+1)&(~1)]= xpos>>16;
683 return fragmentPos + 1;
694 int srcRange,
const int table[4],
int dstRange,
695 int brightness,
int contrast,
int saturation)
719 int *srcRange,
int **table,
int *dstRange,
720 int *brightness,
int *contrast,
int *saturation)
759 int usesVFilter, usesHFilter;
766 int dst_stride =
FFALIGN(dstW *
sizeof(int16_t) + 16, 16), dst_stride_px = dst_stride >> 1;
776 unscaled = (srcW == dstW && srcH == dstH);
798 if(!i || (i & (i-1))) {
803 if (srcW<4 || srcH<1 || dstW<8 || dstH<1) {
805 srcW, srcH, dstW, dstH);
809 if (!dstFilter) dstFilter= &dummyFilter;
810 if (!srcFilter) srcFilter= &dummyFilter;
812 c->
lumXInc= (((int64_t)srcW<<16) + (dstW>>1))/dstW;
813 c->
lumYInc= (((int64_t)srcH<<16) + (dstH>>1))/dstH;
816 c->
vRounder= 4* 0x0001000100010001ULL;
840 "full chroma interpolation for destination format '%s' not yet implemented\n",
889 c->
canMMX2BeUsed= (dstW >=srcW && (dstW&31)==0 && (srcW&15)==0) ? 1 : 0;
892 av_log(c,
AV_LOG_INFO,
"output width is not a multiple of 32 -> no MMX2 scaler\n");
908 if (flags&SWS_FAST_BILINEAR) {
915 c->
lumXInc = ((int64_t)(srcW-2)<<16)/(dstW-2) - 20;
931 #elif HAVE_VIRTUALALLOC
956 const int filterAlign=
962 srcW , dstW, filterAlign, 1<<14,
968 (flags&SWS_BICUBLIN) ? (flags|
SWS_BILINEAR) : flags, cpu_flags,
976 const int filterAlign=
982 srcH , dstH, filterAlign, (1<<12),
998 short *p = (
short *)&c->vYCoeffsBank[i];
1005 short *p = (
short *)&c->vCCoeffsBank[i];
1015 for (i=0; i<dstH; i++) {
1016 int chrI = (int64_t) i * c->
chrDstH / dstH;
1057 memset(c->
chrUPixBuf[i], 64, dst_stride*2+1);
1105 #if FF_API_SWS_GETCONTEXT
1126 c->
param[0] = param[0];
1127 c->
param[1] = param[1];
1141 float lumaSharpen,
float chromaSharpen,
1142 float chromaHShift,
float chromaVShift,
1149 if (lumaGBlur!=0.0) {
1157 if (chromaGBlur!=0.0) {
1165 if (chromaSharpen!=0.0) {
1174 if (lumaSharpen!=0.0) {
1183 if (chromaHShift != 0.0)
1186 if (chromaVShift != 0.0)
1214 const int length= (int)(variance*quality + 0.5) | 1;
1216 double middle= (length-1)*0.5;
1222 for (i=0; i<length; i++) {
1223 double dist= i-middle;
1224 vec->
coeff[i]= exp(-dist*dist/(2*variance*variance)) / sqrt(2*variance*
M_PI);
1240 for (i=0; i<length; i++)
1256 for (i=0; i<a->
length; i++)
1266 for (i=0; i<a->
length; i++)
1267 a->
coeff[i]*= scalar;
1284 for (i=0; i<a->
length; i++) {
1285 for (j=0; j<b->
length; j++) {
1333 for (i=0; i<a->
length; i++) {
1396 for (i=0; i<a->
length; i++)
1399 for (i=0; i<a->
length; i++)
1404 for (i=0; i<a->
length; i++) {
1405 int x= (int)((a->
coeff[i]-min)*60.0/range +0.5);
1406 av_log(log_ctx, log_level,
"%1.3f ", a->
coeff[i]);
1407 for (;x>0; x--)
av_log(log_ctx, log_level,
" ");
1408 av_log(log_ctx, log_level,
"|\n");
1422 if (!filter)
return;
1470 #ifdef MAP_ANONYMOUS
1473 #elif HAVE_VIRTUALALLOC
1498 param = default_param;
1501 (context->
srcW != srcW ||
1502 context->
srcH != srcH ||
1504 context->
dstW != dstW ||
1505 context->
dstH != dstH ||
1507 context->
flags != flags ||
1508 context->
param[0] != param[0] ||
1509 context->
param[1] != param[1])) {
1526 context->
param[0] = param[0];
1527 context->
param[1] = param[1];
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
int16_t ** alpPixBuf
Ring buffer for scaled horizontal alpha plane lines to be fed to the vertical scaler.
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
#define AV_CPU_FLAG_ALTIVEC
standard
ptrdiff_t uv_off_px
offset (in pixels) between u and v planes
int sws_isSupportedOutput(enum PixelFormat pix_fmt)
Return a positive value if pix_fmt is a supported output format, 0 otherwise.
static SwsVector * sws_sumVec(SwsVector *a, SwsVector *b)
void sws_freeVec(SwsVector *a)
Y , 1bpp, 0 is white, 1 is black, in each byte pixels are ordered from the msb to the lsb...
planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (firs...
int chrSrcH
Height of source chroma planes.
static int initFilter(int16_t **outFilter, int32_t **filterPos, int *outFilterSize, int xInc, int srcW, int dstW, int filterAlign, int one, int flags, int cpu_flags, SwsVector *srcFilter, SwsVector *dstFilter, double param[2], int is_horizontal)
planar YUV 4:2:2, 18bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
void sws_rgb2rgb_init(void)
static const FormatEntry format_entries[PIX_FMT_NB]
packed BGR 4:4:4, 16bpp, (msb)4A 4B 4G 4R(lsb), big-endian, most significant bits to 1 ...
int av_get_bits_per_pixel(const AVPixFmtDescriptor *pixdesc)
Return the number of bits per pixel used by the pixel format described by pixdesc.
planar GBR 4:4:4 27bpp, little endian
#define SWS_FAST_BILINEAR
void sws_convVec(SwsVector *a, SwsVector *b)
void av_opt_set_defaults(void *s)
Set the values of all AVOption fields to their default values.
int vChrDrop
Binary logarithm of extra vertical subsampling factor in source image chroma planes specified by user...
int ff_yuv2rgb_c_init_tables(SwsContext *c, const int inv_table[4], int fullRange, int brightness, int contrast, int saturation)
static double getSplineCoeff(double a, double b, double c, double d, double dist)
number of pixel formats, DO NOT USE THIS if you want to link with shared libav* because the number of...
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV422P and setting color_...
int dstFormatBpp
Number of bits per pixel of the destination pixel format.
#define AV_CPU_FLAG_MMX2
SSE integer functions or AMD MMX ext.
planar YUV 4:2:0, 24bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
SwsContext * sws_getContext(int srcW, int srcH, enum PixelFormat srcFormat, int dstW, int dstH, enum PixelFormat dstFormat, int flags, SwsFilter *srcFilter, SwsFilter *dstFilter, const double *param)
Allocate and return an SwsContext.
int srcRange
0 = MPG YUV range, 1 = JPG YUV range (source image).
SwsFunc swScale
Note that src, dst, srcStride, dstStride will be copied in the sws_scale() wrapper so they can be fre...
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
enum PixelFormat srcFormat
Source pixel format.
#define SWS_FULL_CHR_H_INT
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
void sws_freeFilter(SwsFilter *filter)
int srcH
Height of source luma/alpha planes.
unsigned swscale_version(void)
Return the LIBSWSCALE_VERSION_INT constant.
planar YUV 4:2:2, 32bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV444P and setting color_...
planar YUV 4:2:0, 24bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
packed RGB 3:3:2, 8bpp, (msb)2R 3G 3B(lsb)
int chrMmx2FilterCodeSize
Runtime-generated MMX2 horizontal fast bilinear scaler code size for chroma planes.
int chrDstVSubSample
Binary logarithm of vertical subsampling factor between luma/alpha and chroma planes in destination i...
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
packed YUV 4:1:1, 12bpp, Cb Y0 Y1 Cr Y2 Y3
int length
number of coefficients in the vector
packed BGR 5:5:5, 16bpp, (msb)1A 5B 5G 5R(lsb), little-endian, most significant bit to 1 ...
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
int vChrFilterSize
Vertical filter size for chroma pixels.
packed RGB 4:4:4, 16bpp, (msb)4A 4R 4G 4B(lsb), little-endian, most significant bits to 0 ...
int16_t ** lumPixBuf
Ring buffer for scaled horizontal luma plane lines to be fed to the vertical scaler.
uint8_t * chrMmx2FilterCode
Runtime-generated MMX2 horizontal fast bilinear scaler code for chroma planes.
int sws_init_context(SwsContext *c, SwsFilter *srcFilter, SwsFilter *dstFilter)
Initialize the swscaler context sws_context.
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV420P and setting color_...
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, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as lit...
external api for the swscale stuff
packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), big-endian
void sws_freeContext(SwsContext *c)
Free the swscaler context swsContext.
planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
int chrSrcHSubSample
Binary logarithm of horizontal subsampling factor between luma/alpha and chroma planes in source imag...
packed BGR 5:6:5, 16bpp, (msb) 5B 6G 5R(lsb), little-endian
static SwsVector * sws_getShiftedVec(SwsVector *a, int shift)
#define ROUNDED_DIV(a, b)
int32_t * vChrFilterPos
Array of vertical filter starting positions for each dst[i] for chroma planes.
Y , 16bpp, little-endian.
int dstH
Height of destination luma/alpha planes.
uint16_t depth_minus1
number of bits in the component minus 1
packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), little-endian
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
int sws_setColorspaceDetails(struct SwsContext *c, const int inv_table[4], int srcRange, const int table[4], int dstRange, int brightness, int contrast, int saturation)
SwsContext * sws_alloc_context(void)
Allocate an empty SwsContext.
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
int16_t ** chrVPixBuf
Ring buffer for scaled horizontal chroma plane lines to be fed to the vertical scaler.
int32_t * hChrFilterPos
Array of horizontal filter starting positions for each dst[i] for chroma planes.
int hLumFilterSize
Horizontal filter size for luma/alpha pixels.
SwsFunc ff_getSwsFunc(SwsContext *c)
Return function pointer to fastest main scaler path function depending on architecture and available ...
void sws_scaleVec(SwsVector *a, double scalar)
Scale all the coefficients of a by the scalar value.
planar YUV 4:4:4, 27bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
#define SWS_SRC_V_CHR_DROP_MASK
planar YUV 4:2:0, 15bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as big...
packed BGR 5:6:5, 16bpp, (msb) 5B 6G 5R(lsb), big-endian
void av_log(void *avcl, int level, const char *fmt,...)
#define SWS_FULL_CHR_H_INP
planar GBR 4:4:4 27bpp, big endian
static int initMMX2HScaler(int dstW, int xInc, uint8_t *filterCode, int16_t *filter, int32_t *filterPos, int numSplits)
SwsVector * sws_allocVec(int length)
Allocate and return an uninitialized vector with length coefficients.
int vChrBufSize
Number of vertical chroma lines allocated in the ring buffer.
const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB]
The array of all the pixel format descriptors.
int chrDstW
Width of destination chroma planes.
#define LIBSWSCALE_VERSION_INT
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
static av_always_inline void emms_c(void)
Empty mmx state.
int32_t * hLumFilterPos
Array of horizontal filter starting positions for each dst[i] for luma/alpha planes.
int hChrFilterSize
Horizontal filter size for chroma pixels.
static void filter(MpegAudioContext *s, int ch, const short *samples, int incr)
ptrdiff_t uv_off_byte
offset (in bytes) between u and v planes
int dstRange
0 = MPG YUV range, 1 = JPG YUV range (destination image).
packed RGB 1:2:1, 8bpp, (msb)1B 2G 1R(lsb)
packed RGB 1:2:1 bitstream, 4bpp, (msb)1R 2G 1B(lsb), a byte contains two pixels, the first pixel in ...
uint8_t * formatConvBuffer
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.
packed RGB 1:2:1, 8bpp, (msb)1R 2G 1B(lsb)
int vLumBufSize
Number of vertical luma/alpha lines allocated in the ring buffer.
packed RGB 4:4:4, 16bpp, (msb)4A 4R 4G 4B(lsb), big-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 big...
planar YUV 4:4:4, 27bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
void ff_yuv2rgb_init_tables_altivec(SwsContext *c, const int inv_table[4], int brightness, int contrast, int saturation)
planar YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
planar YUV 4:2:2, 32bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
int16_t ** chrUPixBuf
Ring buffer for scaled horizontal chroma plane lines to be fed to the vertical scaler.
int sws_getColorspaceDetails(struct SwsContext *c, int **inv_table, int *srcRange, int **table, int *dstRange, int *brightness, int *contrast, int *saturation)
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of PIX_FMT_YUV440P and setting color_range ...
SwsFilter * sws_getDefaultFilter(float lumaGBlur, float chromaGBlur, float lumaSharpen, float chromaSharpen, float chromaHShift, float chromaVShift, int verbose)
static int handle_jpeg(enum PixelFormat *format)
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 lumMmx2FilterCodeSize
Runtime-generated MMX2 horizontal fast bilinear scaler code size for luma/alpha planes.
const char * swscale_configuration(void)
Return the libswscale build-time configuration.
as above, but U and V bytes are swapped
SwsVector * sws_getConstVec(double c, int length)
Allocate and return a vector with length coefficients, all with the same value c. ...
int srcColorspaceTable[4]
int dstW
Width of destination luma/alpha planes.
planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
planar YUV 4:2:0, 13.5bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
planar GBR 4:4:4 30bpp, big endian
#define AV_CPU_FLAG_3DNOW
AMD 3DNOW.
int32_t * vLumFilterPos
Array of vertical filter starting positions for each dst[i] for luma/alpha planes.
double * coeff
pointer to the list of coefficients
packed BGR 4:4:4, 16bpp, (msb)4A 4B 4G 4R(lsb), little-endian, most significant bits to 1 ...
int dstColorspaceTable[4]
void(* rgb15to16)(const uint8_t *src, uint8_t *dst, int src_size)
const AVClass * av_class
info on struct for av_log
#define AV_CPU_FLAG_MMX
standard MMX
#define SWS_PARAM_DEFAULT
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
int chrDstH
Height of destination chroma planes.
void sws_normalizeVec(SwsVector *a, double height)
Scale all the coefficients of a so that their sum equals height.
packed RGB 1:2:1 bitstream, 4bpp, (msb)1B 2G 1R(lsb), a byte contains two pixels, the first pixel in ...
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
packed RGB 5:5:5, 16bpp, (msb)1A 5R 5G 5B(lsb), big-endian, most significant bit to 0 ...
packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr
planar GBR 4:4:4 48bpp, little endian
planar YUV 4:2:0, 13.5bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
static SwsVector * sws_diffVec(SwsVector *a, SwsVector *b)
void * av_malloc(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
Describe the class of an AVClass context structure.
packed RGB 5:5:5, 16bpp, (msb)1A 5R 5G 5B(lsb), little-endian, most significant bit to 0 ...
packed BGR 5:5:5, 16bpp, (msb)1A 5B 5G 5R(lsb), big-endian, most significant bit to 1 ...
SwsVector * sws_getIdentityVec(void)
Allocate and return a vector with just one coefficient, with value 1.0.
packed RGB 3:3:2, 8bpp, (msb)2B 3G 3R(lsb)
int vLumFilterSize
Vertical filter size for luma/alpha pixels.
const char * sws_format_name(enum PixelFormat format)
void sws_shiftVec(SwsVector *a, int shift)
#define SWS_SRC_V_CHR_DROP_SHIFT
int16_t * vChrFilter
Array of vertical filter coefficients for chroma planes.
packed RGB 8:8:8, 24bpp, BGRBGR...
int av_get_cpu_flags(void)
Return the flags which specify extensions supported by the CPU.
int16_t * hLumFilter
Array of horizontal filter coefficients for luma/alpha planes.
void sws_subVec(SwsVector *a, SwsVector *b)
int sws_isSupportedInput(enum PixelFormat pix_fmt)
Return a positive value if pix_fmt is a supported input format, 0 otherwise.
packed RGB 16:16:16, 48bpp, 16B, 16G, 16R, the 2-byte value for each R/G/B component is stored as lit...
static void getSubSampleFactors(int *h, int *v, enum PixelFormat format)
const char * swscale_license(void)
Return the libswscale license.
planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
const AVClass sws_context_class
static double sws_dcVec(SwsVector *a)
planar YUV 4:2:0, 15bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
double param[2]
Input parameters for scaling algorithms that need them.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1
#define FF_ALLOC_OR_GOTO(ctx, p, size, label)
#define SWS_MAX_REDUCE_CUTOFF
8 bit with PIX_FMT_RGB32 palette
planar YUV 4:2:2, 18bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
planar GBR 4:4:4 48bpp, big endian
planar YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
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 8:8:8, 24bpp, RGBRGB...
int srcFormatBpp
Number of bits per pixel of the source pixel format.
struct FormatEntry FormatEntry
planar GBR 4:4:4 30bpp, little endian
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
int16_t * vLumFilter
Array of vertical filter coefficients for luma/alpha planes.
int16_t * hChrFilter
Array of horizontal filter coefficients for chroma planes.
packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
enum PixelFormat dstFormat
Destination pixel format.
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...
struct SwsContext * sws_getCachedContext(struct SwsContext *context, int srcW, int srcH, enum PixelFormat srcFormat, int dstW, int dstH, enum PixelFormat dstFormat, int flags, SwsFilter *srcFilter, SwsFilter *dstFilter, const double *param)
Check if context can be reused, otherwise reallocate a new one.
void sws_addVec(SwsVector *a, SwsVector *b)
#define FF_ALLOCZ_OR_GOTO(ctx, p, size, label)
const int32_t ff_yuv2rgb_coeffs[8][4]
static SwsVector * sws_getConvVec(SwsVector *a, SwsVector *b)
planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
uint8_t * lumMmx2FilterCode
Runtime-generated MMX2 horizontal fast bilinear scaler code for luma/alpha planes.