Mercurial > mplayer.hg
changeset 13373:6bd869a18d2c
passing an array or double precission parameters for the scaling function, instead of missusing a few bits of the flags
fixing the naming of the scaling functions a little
author | michael |
---|---|
date | Sat, 18 Sep 2004 00:08:17 +0000 |
parents | c537796e79b7 |
children | e94036364011 |
files | DOCS/man/en/mplayer.1 TOOLS/mwallp/jpeg.c libmpcodecs/vf_sab.c libmpcodecs/vf_scale.c libmpcodecs/vf_smartblur.c postproc/swscale.c postproc/swscale.h postproc/swscale_internal.h spudec.c |
diffstat | 9 files changed, 57 insertions(+), 38 deletions(-) [+] |
line wrap: on
line diff
--- a/DOCS/man/en/mplayer.1 Fri Sep 17 21:15:52 2004 +0000 +++ b/DOCS/man/en/mplayer.1 Sat Sep 18 00:08:17 2004 +0000 @@ -3291,7 +3291,7 @@ .IPs 9 lanczos .IPs 10 -bicubic spline +natural bicubic spline .RE .PD 1 .sp 1 @@ -3549,7 +3549,7 @@ portrait and not landscape. . .TP -.B scale[=w:h[:interlaced[:chr_drop[:param[:presize]]]]] +.B scale[=w:h[:interlaced[:chr_drop[:param[:param2[:presize]]]]]] Scales the image with the software scaler (slow) and performs a YUV<\->RGB colorspace conversion (also see \-sws). .RSs @@ -3582,9 +3582,19 @@ 3: Use only every 8. input line for chroma. .REss .IPs param -scaling parameter (depends upon the scaling method used) +scaling parameters (depend upon the scaling method used) .RSss -\-sws 2 (bicubic): sharpness (0 (soft) \- 100 (sharp)) +\-sws 2 (bicubic): B (blurring) and C (ringing) +.br +(0.00, 0.60) default +.br +(0.00, 0.75) VirtualDubs "precise bicubic" +.br +(0.00, 0.50) Catmull-Rom spline +.br +(0.33, 0.33) Mitchell-Netravali spline +.br +(1.00, 0.00) cubic B-spline .br \-sws 7 (gaussian): sharpness (0 (soft) \- 100 (sharp)) .br
--- a/TOOLS/mwallp/jpeg.c Fri Sep 17 21:15:52 2004 +0000 +++ b/TOOLS/mwallp/jpeg.c Sat Sep 18 00:08:17 2004 +0000 @@ -135,7 +135,7 @@ jpeg_destroy_decompress(&cinfo); swsContext= sws_getContext(width,height, in_fmt, - dwidth,dheight, IMGFMT_BGR|dbpp, SWS_BICUBIC, NULL, NULL); + dwidth,dheight, IMGFMT_BGR|dbpp, SWS_BICUBIC, NULL, NULL, NULL); sws_scale(swsContext,&img,&row_stride,0,height,&dbuffer, &dstride);
--- a/libmpcodecs/vf_sab.c Fri Sep 17 21:15:52 2004 +0000 +++ b/libmpcodecs/vf_sab.c Sat Sep 18 00:08:17 2004 +0000 @@ -100,7 +100,7 @@ swsF.lumH= swsF.lumV= vec; swsF.chrH= swsF.chrV= NULL; f->preFilterContext= sws_getContext( - width, height, IMGFMT_Y8, width, height, IMGFMT_Y8, get_sws_cpuflags(), &swsF, NULL); + width, height, IMGFMT_Y8, width, height, IMGFMT_Y8, get_sws_cpuflags(), &swsF, NULL, NULL); sws_freeVec(vec); vec = sws_getGaussianVec(f->strength, 5.0);
--- a/libmpcodecs/vf_scale.c Fri Sep 17 21:15:52 2004 +0000 +++ b/libmpcodecs/vf_scale.c Sat Sep 18 00:08:17 2004 +0000 @@ -21,7 +21,7 @@ static struct vf_priv_s { int w,h; int v_chr_drop; - int param; + double param[2]; unsigned int fmt; struct SwsContext *ctx; struct SwsContext *ctx2; //for interlaced slices only @@ -31,7 +31,7 @@ } vf_priv_dflt = { -1,-1, 0, - 0, + {SWS_PARAM_DEFAULT, SWS_PARAM_DEFAULT}, 0, NULL, NULL, @@ -186,18 +186,17 @@ // new swscaler: sws_getFlagsAndFilterFromCmdLine(&int_sws_flags, &srcFilter, &dstFilter); int_sws_flags|= vf->priv->v_chr_drop << SWS_SRC_V_CHR_DROP_SHIFT; - int_sws_flags|= vf->priv->param << SWS_PARAM_SHIFT; vf->priv->ctx=sws_getContext(width, height >> vf->priv->interlaced, outfmt, vf->priv->w, vf->priv->h >> vf->priv->interlaced, best, - int_sws_flags | get_sws_cpuflags(), srcFilter, dstFilter); + int_sws_flags | get_sws_cpuflags(), srcFilter, dstFilter, vf->priv->param); if(vf->priv->interlaced){ vf->priv->ctx2=sws_getContext(width, height >> 1, outfmt, vf->priv->w, vf->priv->h >> 1, best, - int_sws_flags | get_sws_cpuflags(), srcFilter, dstFilter); + int_sws_flags | get_sws_cpuflags(), srcFilter, dstFilter, vf->priv->param); } if(!vf->priv->ctx){ // error... @@ -438,14 +437,16 @@ vf->priv->w= vf->priv->h=-1; vf->priv->v_chr_drop=0; - vf->priv->param=0; + vf->priv->param[0]= + vf->priv->param[1]=SWS_PARAM_DEFAULT; vf->priv->palette=NULL; } // if(!vf->priv) - if(args) sscanf(args, "%d:%d:%d:%d", + if(args) sscanf(args, "%d:%d:%d:%lf:%lf", &vf->priv->w, &vf->priv->h, &vf->priv->v_chr_drop, - &vf->priv->param); + &vf->priv->param[0], + &vf->priv->param[1]); mp_msg(MSGT_VFILTER,MSGL_V,"SwScale params: %d x %d (-1=no scaling)\n", vf->priv->w, vf->priv->h); @@ -524,7 +525,7 @@ SwsFilter *dstFilterParam, *srcFilterParam; sws_getFlagsAndFilterFromCmdLine(&flags, &srcFilterParam, &dstFilterParam); - return sws_getContext(srcW, srcH, srcFormat, dstW, dstH, dstFormat, flags | get_sws_cpuflags(), srcFilterParam, dstFilterParam); + return sws_getContext(srcW, srcH, srcFormat, dstW, dstH, dstFormat, flags | get_sws_cpuflags(), srcFilterParam, dstFilterParam, NULL); } /// An example of presets usage @@ -572,7 +573,8 @@ {"h", ST_OFF(h), CONF_TYPE_INT, M_OPT_MIN,-3 ,0, NULL}, {"interlaced", ST_OFF(interlaced), CONF_TYPE_INT, M_OPT_RANGE, 0, 1, NULL}, {"chr-drop", ST_OFF(v_chr_drop), CONF_TYPE_INT, M_OPT_RANGE, 0, 3, NULL}, - {"param", ST_OFF(param), CONF_TYPE_INT, M_OPT_RANGE, 0, 100, NULL}, + {"param" , ST_OFF(param[0]), CONF_TYPE_DOUBLE, M_OPT_RANGE, 0.0, 100.0, NULL}, + {"param2", ST_OFF(param[1]), CONF_TYPE_DOUBLE, M_OPT_RANGE, 0.0, 100.0, NULL}, // Note that here the 2 field is NULL (ie 0) // As we want this option to act on the option struct itself {"presize", 0, CONF_TYPE_OBJ_PRESETS, 0, 0, 0, &size_preset},
--- a/libmpcodecs/vf_smartblur.c Fri Sep 17 21:15:52 2004 +0000 +++ b/libmpcodecs/vf_smartblur.c Sat Sep 18 00:08:17 2004 +0000 @@ -95,7 +95,7 @@ swsF.lumH= swsF.lumV= vec; swsF.chrH= swsF.chrV= NULL; f->filterContext= sws_getContext( - width, height, IMGFMT_Y8, width, height, IMGFMT_Y8, get_sws_cpuflags(), &swsF, NULL); + width, height, IMGFMT_Y8, width, height, IMGFMT_Y8, get_sws_cpuflags(), &swsF, NULL, NULL); sws_freeVec(vec);
--- a/postproc/swscale.c Fri Sep 17 21:15:52 2004 +0000 +++ b/postproc/swscale.c Sat Sep 18 00:08:17 2004 +0000 @@ -775,7 +775,7 @@ static inline void initFilter(int16_t **outFilter, int16_t **filterPos, int *outFilterSize, int xInc, int srcW, int dstW, int filterAlign, int one, int flags, - SwsVector *srcFilter, SwsVector *dstFilter) + SwsVector *srcFilter, SwsVector *dstFilter, double param[2]) { int i; int filterSize; @@ -855,13 +855,12 @@ double xDstInSrc; double sizeFactor, filterSizeInSrc; const double xInc1= (double)xInc / (double)(1<<16); - int param= (flags&SWS_PARAM_MASK)>>SWS_PARAM_SHIFT; if (flags&SWS_BICUBIC) sizeFactor= 4.0; else if(flags&SWS_X) sizeFactor= 8.0; else if(flags&SWS_AREA) sizeFactor= 1.0; //downscale only, for upscale it is bilinear else if(flags&SWS_GAUSS) sizeFactor= 8.0; // infinite ;) - else if(flags&SWS_LANCZOS) sizeFactor= param ? 2.0*param : 6.0; + else if(flags&SWS_LANCZOS) sizeFactor= param[0] != SWS_PARAM_DEFAULT ? 2.0*param[0] : 6.0; else if(flags&SWS_SINC) sizeFactor= 20.0; // infinite ;) else if(flags&SWS_SPLINE) sizeFactor= 20.0; // infinite ;) else if(flags&SWS_BILINEAR) sizeFactor= 2.0; @@ -890,13 +889,13 @@ double coeff; if(flags & SWS_BICUBIC) { - double A= param ? -param*0.01 : -0.60; - - // Equation is from VirtualDub - if(d<1.0) - coeff = (1.0 - (A+3.0)*d*d + (A+2.0)*d*d*d); + double B= param[0] != SWS_PARAM_DEFAULT ? param[0] : 0.0; + double C= param[1] != SWS_PARAM_DEFAULT ? param[1] : 0.6; + + if(d<1.0) + coeff = (12-9*B-6*C)*d*d*d + (-18+12*B+6*C)*d*d + 6-2*B; else if(d<2.0) - coeff = (-4.0*A + 8.0*A*d - 5.0*A*d*d + A*d*d*d); + coeff = (-B-6*C)*d*d*d + (6*B+30*C)*d*d + (-12*B-48*C)*d +8*B+24*C; else coeff=0.0; } @@ -908,7 +907,7 @@ }*/ else if(flags & SWS_X) { - double A= param ? param*0.1 : 1.0; + double A= param[0] != SWS_PARAM_DEFAULT ? param[0] : 1.0; if(d<1.0) coeff = cos(d*PI); @@ -927,7 +926,7 @@ } else if(flags & SWS_GAUSS) { - double p= param ? param*0.1 : 3.0; + double p= param[0] != SWS_PARAM_DEFAULT ? param[0] : 3.0; coeff = pow(2.0, - p*d*d); } else if(flags & SWS_SINC) @@ -936,7 +935,7 @@ } else if(flags & SWS_LANCZOS) { - double p= param ? param : 3.0; + double p= param[0] != SWS_PARAM_DEFAULT ? param[0] : 3.0; coeff = d ? sin(d*PI)*sin(d*PI/p)/(d*d*PI*PI/p) : 1.0; if(d>p) coeff=0; } @@ -1748,7 +1747,7 @@ } SwsContext *sws_getContext(int srcW, int srcH, int origSrcFormat, int dstW, int dstH, int origDstFormat, int flags, - SwsFilter *srcFilter, SwsFilter *dstFilter){ + SwsFilter *srcFilter, SwsFilter *dstFilter, double *param){ SwsContext *c; int i; @@ -1847,6 +1846,14 @@ if((isBGR(srcFormat) || isRGB(srcFormat)) && !(flags&SWS_FULL_CHR_H_INP)) c->chrSrcHSubSample=1; + if(param){ + c->param[0] = param[0]; + c->param[1] = param[1]; + }else{ + c->param[0] = + c->param[1] = SWS_PARAM_DEFAULT; + } + c->chrIntHSubSample= c->chrDstHSubSample; c->chrIntVSubSample= c->chrSrcVSubSample; @@ -1982,11 +1989,11 @@ initFilter(&c->hLumFilter, &c->hLumFilterPos, &c->hLumFilterSize, c->lumXInc, srcW , dstW, filterAlign, 1<<14, (flags&SWS_BICUBLIN) ? (flags|SWS_BICUBIC) : flags, - srcFilter->lumH, dstFilter->lumH); + srcFilter->lumH, dstFilter->lumH, c->param); initFilter(&c->hChrFilter, &c->hChrFilterPos, &c->hChrFilterSize, c->chrXInc, c->chrSrcW, c->chrDstW, filterAlign, 1<<14, (flags&SWS_BICUBLIN) ? (flags|SWS_BILINEAR) : flags, - srcFilter->chrH, dstFilter->chrH); + srcFilter->chrH, dstFilter->chrH, c->param); #ifdef ARCH_X86 // can't downscale !!! @@ -2014,11 +2021,11 @@ initFilter(&c->vLumFilter, &c->vLumFilterPos, &c->vLumFilterSize, c->lumYInc, srcH , dstH, filterAlign, (1<<12)-4, (flags&SWS_BICUBLIN) ? (flags|SWS_BICUBIC) : flags, - srcFilter->lumV, dstFilter->lumV); + srcFilter->lumV, dstFilter->lumV, c->param); initFilter(&c->vChrFilter, &c->vChrFilterPos, &c->vChrFilterSize, c->chrYInc, c->chrSrcH, c->chrDstH, filterAlign, (1<<12)-4, (flags&SWS_BICUBLIN) ? (flags|SWS_BILINEAR) : flags, - srcFilter->chrV, dstFilter->chrV); + srcFilter->chrV, dstFilter->chrV, c->param); } // Calculate Buffer Sizes so that they won't run out while handling these damn slices
--- a/postproc/swscale.h Fri Sep 17 21:15:52 2004 +0000 +++ b/postproc/swscale.h Sat Sep 18 00:08:17 2004 +0000 @@ -45,8 +45,7 @@ #define SWS_SRC_V_CHR_DROP_MASK 0x30000 #define SWS_SRC_V_CHR_DROP_SHIFT 16 -#define SWS_PARAM_MASK 0x3FC0000 -#define SWS_PARAM_SHIFT 18 +#define SWS_PARAM_DEFAULT 123456 #define SWS_PRINT_INFO 0x1000 @@ -94,7 +93,7 @@ void sws_freeContext(struct SwsContext *swsContext); struct SwsContext *sws_getContext(int srcW, int srcH, int srcFormat, int dstW, int dstH, int dstFormat, int flags, - SwsFilter *srcFilter, SwsFilter *dstFilter); + SwsFilter *srcFilter, SwsFilter *dstFilter, double *param); int sws_scale(struct SwsContext *context, uint8_t* src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t* dst[], int dstStride[]); int sws_scale_ordered(struct SwsContext *context, uint8_t* src[], int srcStride[], int srcSliceY,
--- a/postproc/swscale_internal.h Fri Sep 17 21:15:52 2004 +0000 +++ b/postproc/swscale_internal.h Sat Sep 18 00:08:17 2004 +0000 @@ -54,6 +54,7 @@ int chrIntHSubSample, chrIntVSubSample; int chrDstHSubSample, chrDstVSubSample; int vChrDrop; + double param[2]; int16_t **lumPixBuf; int16_t **chrPixBuf;
--- a/spudec.c Fri Sep 17 21:15:52 2004 +0000 +++ b/spudec.c Sat Sep 18 00:08:17 2004 +0000 @@ -752,7 +752,7 @@ oldvar = spu_gaussvar; } - ctx=sws_getContext(sw, sh, IMGFMT_Y800, dw, dh, IMGFMT_Y800, SWS_GAUSS, &filter, NULL); + ctx=sws_getContext(sw, sh, IMGFMT_Y800, dw, dh, IMGFMT_Y800, SWS_GAUSS, &filter, NULL, NULL); sws_scale(ctx,&s1,&ss,0,sh,&d1,&ds); for (i=ss*sh-1; i>=0; i--) if (!s2[i]) s2[i] = 255; //else s2[i] = 1; sws_scale(ctx,&s2,&ss,0,sh,&d2,&ds);