Mercurial > mplayer.hg
changeset 4402:67abbf501b02
area averageing scaling support (-sws 5) (is identical to bilinear for upscale)
author | michael |
---|---|
date | Tue, 29 Jan 2002 01:43:15 +0000 |
parents | 8d00348d0d6b |
children | f3dc8bf8383a |
files | postproc/swscale.c postproc/swscale.h |
diffstat | 2 files changed, 18 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/postproc/swscale.c Mon Jan 28 23:57:18 2002 +0000 +++ b/postproc/swscale.c Tue Jan 29 01:43:15 2002 +0000 @@ -604,6 +604,7 @@ case 2: flags|= SWS_BICUBIC; break; case 3: flags|= SWS_X; break; case 4: flags|= SWS_POINT; break; + case 5: flags|= SWS_AREA; break; default:flags|= SWS_BILINEAR; break; } @@ -666,7 +667,7 @@ int xDstInSrc; if (flags&SWS_BICUBIC) filterSize= 4; else if(flags&SWS_X ) filterSize= 4; - else filterSize= 2; + else filterSize= 2; // SWS_BILINEAR / SWS_AREA // printf("%d %d %d\n", filterSize, srcW, dstW); filter= (double*)memalign(8, dstW*sizeof(double)*filterSize); @@ -705,6 +706,7 @@ } else { + //Bilinear upscale / linear interpolate / Area averaging for(j=0; j<filterSize; j++) { double d= ABS((xx<<16) - xDstInSrc)/(double)(1<<16); @@ -721,9 +723,10 @@ else // downscale { int xDstInSrc; - if(flags&SWS_BICUBIC) filterSize= (int)ceil(1 + 4.0*srcW / (double)dstW); - else if(flags&SWS_X) filterSize= (int)ceil(1 + 4.0*srcW / (double)dstW); - else filterSize= (int)ceil(1 + 2.0*srcW / (double)dstW); + if(flags&SWS_BICUBIC) filterSize= (int)ceil(1 + 4.0*srcW / (double)dstW); + else if(flags&SWS_X) filterSize= (int)ceil(1 + 4.0*srcW / (double)dstW); + else if(flags&SWS_AREA) filterSize= (int)ceil(1 + 1.0*srcW / (double)dstW); + else /* BILINEAR */ filterSize= (int)ceil(1 + 2.0*srcW / (double)dstW); // printf("%d %d %d\n", *filterSize, srcW, dstW); filter= (double*)memalign(8, dstW*sizeof(double)*filterSize); @@ -749,15 +752,19 @@ else coeff=0.0; } -/* else if(flags & SWS_X) + else if(flags & SWS_AREA) { - }*/ + double srcPixelSize= (1<<16)/(double)xInc; + if(d + srcPixelSize/2 < 0.5) coeff= 1.0; + else if(d - srcPixelSize/2 < 0.5) coeff= (0.5-d)/srcPixelSize + 0.5; + else coeff=0.0; + } else { coeff= 1.0 - d; if(coeff<0) coeff=0; } -// printf("%1.3f %d %d \n", coeff, (int)d, xDstInSrc); +// printf("%1.3f %2.3f %d \n", coeff, d, xDstInSrc); filter[i*filterSize + j]= coeff; xx++; } @@ -1225,7 +1232,9 @@ else if(flags&SWS_BICUBIC) fprintf(stderr, "\nSwScaler: BICUBIC scaler "); else if(flags&SWS_POINT) - fprintf(stderr, "\nSwScaler: POINT scaler "); + fprintf(stderr, "\nSwScaler: Nearest Neighbor / POINT scaler "); + else if(flags&SWS_AREA) + fprintf(stderr, "\nSwScaler: Area Averageing scaler "); else fprintf(stderr, "\nSwScaler: ehh flags invalid?! ");