X-Git-Url: https://git.videolan.org/?p=ffmpeg.git;a=blobdiff_plain;f=libswscale%2Futils.c;h=95edcb42a76fc97d1daea755a6863c1571f72a9a;hp=1a7a36454b0db4d0c3423daf73552c6d3bead160;hb=60222557746d66288f4231ed6ce1bfce7d98de3a;hpb=a4388ebd37e42721e294946721d5c008ca0b3e66;ds=sidebyside diff --git a/libswscale/utils.c b/libswscale/utils.c index 1a7a36454b..95edcb42a7 100644 --- a/libswscale/utils.c +++ b/libswscale/utils.c @@ -65,12 +65,6 @@ const char *swscale_license(void) #define RET 0xC3 //near return opcode for x86 -#ifdef M_PI -#define PI M_PI -#else -#define PI 3.14159265358979323846 -#endif - #define isSupportedIn(x) ( \ (x)==PIX_FMT_YUV420P \ || (x)==PIX_FMT_YUVA420P \ @@ -127,8 +121,7 @@ int sws_isSupportedInput(enum PixelFormat pix_fmt) || (x)==PIX_FMT_YUV444P \ || (x)==PIX_FMT_YUV422P \ || (x)==PIX_FMT_YUV411P \ - || isRGB(x) \ - || isBGR(x) \ + || isAnyRGB(x) \ || (x)==PIX_FMT_NV12 \ || (x)==PIX_FMT_NV21 \ || (x)==PIX_FMT_GRAY16BE \ @@ -299,7 +292,7 @@ static int initFilter(int16_t **outFilter, int16_t **filterPos, int *outFilterSi double c; if (floatd<1.0) - c = cos(floatd*PI); + c = cos(floatd*M_PI); else c=-1.0; if (c<0.0) c= -pow(-c, A); @@ -315,10 +308,10 @@ static int initFilter(int16_t **outFilter, int16_t **filterPos, int *outFilterSi double p= param[0] != SWS_PARAM_DEFAULT ? param[0] : 3.0; coeff = (pow(2.0, - p*floatd*floatd))*fone; } else if (flags & SWS_SINC) { - coeff = (d ? sin(floatd*PI)/(floatd*PI) : 1.0)*fone; + coeff = (d ? sin(floatd*M_PI)/(floatd*M_PI) : 1.0)*fone; } else if (flags & SWS_LANCZOS) { double p= param[0] != SWS_PARAM_DEFAULT ? param[0] : 3.0; - coeff = (d ? sin(floatd*PI)*sin(floatd*PI/p)/(floatd*floatd*PI*PI/p) : 1.0)*fone; + coeff = (d ? sin(floatd*M_PI)*sin(floatd*M_PI/p)/(floatd*floatd*M_PI*M_PI/p) : 1.0)*fone; if (floatd>p) coeff=0; } else if (flags & SWS_BILINEAR) { coeff= (1<<30) - d; @@ -860,6 +853,8 @@ SwsContext *sws_getContext(int srcW, int srcH, enum PixelFormat srcFormat, c->flags= flags; c->dstFormat= dstFormat; c->srcFormat= srcFormat; + c->dstFormatBpp = av_get_bits_per_pixel(&av_pix_fmt_descriptors[dstFormat]); + c->srcFormatBpp = av_get_bits_per_pixel(&av_pix_fmt_descriptors[srcFormat]); c->vRounder= 4* 0x0001000100010001ULL; usesHFilter= usesVFilter= 0; @@ -876,14 +871,14 @@ SwsContext *sws_getContext(int srcW, int srcH, enum PixelFormat srcFormat, getSubSampleFactors(&c->chrDstHSubSample, &c->chrDstVSubSample, dstFormat); // reuse chroma for 2 pixels RGB/BGR unless user wants full chroma interpolation - if ((isBGR(dstFormat) || isRGB(dstFormat)) && !(flags&SWS_FULL_CHR_H_INT)) c->chrDstHSubSample=1; + if (isAnyRGB(dstFormat) && !(flags&SWS_FULL_CHR_H_INT)) c->chrDstHSubSample=1; // drop some chroma lines if the user wants it c->vChrDrop= (flags&SWS_SRC_V_CHR_DROP_MASK)>>SWS_SRC_V_CHR_DROP_SHIFT; c->chrSrcVSubSample+= c->vChrDrop; // drop every other pixel for chroma calculation unless user wants full chroma - if ((isBGR(srcFormat) || isRGB(srcFormat)) && !(flags&SWS_FULL_CHR_H_INP) + if (isAnyRGB(srcFormat) && !(flags&SWS_FULL_CHR_H_INP) && srcFormat!=PIX_FMT_RGB8 && srcFormat!=PIX_FMT_BGR8 && srcFormat!=PIX_FMT_RGB4 && srcFormat!=PIX_FMT_BGR4 && srcFormat!=PIX_FMT_RGB4_BYTE && srcFormat!=PIX_FMT_BGR4_BYTE @@ -907,7 +902,7 @@ SwsContext *sws_getContext(int srcW, int srcH, enum PixelFormat srcFormat, sws_setColorspaceDetails(c, ff_yuv2rgb_coeffs[SWS_CS_DEFAULT], srcRange, ff_yuv2rgb_coeffs[SWS_CS_DEFAULT] /* FIXME*/, dstRange, 0, 1<<16, 1<<16); /* unscaled special cases */ - if (unscaled && !usesHFilter && !usesVFilter && (srcRange == dstRange || isBGR(dstFormat) || isRGB(dstFormat))) { + if (unscaled && !usesHFilter && !usesVFilter && (srcRange == dstRange || isAnyRGB(dstFormat))) { ff_get_unscaled_swscale(c); if (c->swScale) { @@ -1130,9 +1125,7 @@ SwsContext *sws_getContext(int srcW, int srcH, enum PixelFormat srcFormat, av_log(c, AV_LOG_INFO, "using AltiVec\n"); else av_log(c, AV_LOG_INFO, "using C\n"); - } - if (flags & SWS_PRINT_INFO) { if (flags & SWS_CPU_CAPS_MMX) { if (c->canMMX2BeUsed && (flags&SWS_FAST_BILINEAR)) av_log(c, AV_LOG_VERBOSE, "using FAST_BILINEAR MMX2 scaler for horizontal scaling\n"); @@ -1187,8 +1180,6 @@ SwsContext *sws_getContext(int srcW, int srcH, enum PixelFormat srcFormat, av_log(c, AV_LOG_VERBOSE, "using %s YV12->BGR15 converter\n", (flags & SWS_CPU_CAPS_MMX) ? "MMX" : "C"); av_log(c, AV_LOG_VERBOSE, "%dx%d -> %dx%d\n", srcW, srcH, dstW, dstH); - } - if (flags & SWS_PRINT_INFO) { av_log(c, AV_LOG_DEBUG, "lum srcW=%d srcH=%d dstW=%d dstH=%d xInc=%d yInc=%d\n", c->srcW, c->srcH, c->dstW, c->dstH, c->lumXInc, c->lumYInc); av_log(c, AV_LOG_DEBUG, "chr srcW=%d srcH=%d dstW=%d dstH=%d xInc=%d yInc=%d\n", @@ -1287,7 +1278,7 @@ SwsVector *sws_getGaussianVec(double variance, double quality) for (i=0; icoeff[i]= exp(-dist*dist/(2*variance*variance)) / sqrt(2*variance*PI); + vec->coeff[i]= exp(-dist*dist/(2*variance*variance)) / sqrt(2*variance*M_PI); } sws_normalizeVec(vec, 1.0);