I pulled out getcoeff() from initFilter(), as a step for simplify the code.
The patch attached is the relevant part.
This patch changes output of swscale-example
for example:
- yuv420p 96x96 -> rgb565 64x 64 flags=32 SSD= 79, 983, 746
+ yuv420p 96x96 -> rgb565 64x 64 flags=32 SSD= 77, 980, 738
only a (relative) small number of lines are affected, but it's
nonetheless strange that moving code makes different output.
Does anyone have any idea about how this can happens?
--
Keiji Costantini
diff --git a/swscale.c b/swscale.c
index dce28f2..32bcba1 100644
--- a/swscale.c
+++ b/swscale.c
@@ -891,6 +891,77 @@ static inline void x86_meminit(int flags){
}
#endif /* defined(ARCH_X86) */
+static inline double getcoeff(int flags, double *param, double d, const int
xInc1){
+ double coeff;
+ if (flags & SWS_BICUBIC)
+ {
+ 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 = (-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;
+ }
+/* else if (flags & SWS_X)
+ {
+ double p= param ? param*0.01 : 0.3;
+ coeff = d ? sin(d*PI)/(d*PI) : 1.0;
+ coeff*= pow(2.0, - p*d*d);
+ }*/
+ else if (flags & SWS_X)
+ {
+ double A= param[0] != SWS_PARAM_DEFAULT ? param[0] : 1.0;
+
+ if (d<1.0)
+ coeff = cos(d*PI);
+ else
+ coeff=-1.0;
+ if (coeff<0.0) coeff= -pow(-coeff, A);
+ else coeff= pow( coeff, A);
+ coeff= coeff*0.5 + 0.5;
+ }
+ else if (flags & SWS_AREA)
+ {
+ double srcPixelSize= 1.0/xInc1;
+ 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 if (flags & SWS_GAUSS)
+ {
+ double p= param[0] != SWS_PARAM_DEFAULT ? param[0] : 3.0;
+ coeff = pow(2.0, - p*d*d);
+ }
+ else if (flags & SWS_SINC)
+ {
+ coeff = d ? sin(d*PI)/(d*PI) : 1.0;
+ }
+ else if (flags & SWS_LANCZOS)
+ {
+ 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;
+ }
+ else if (flags & SWS_BILINEAR)
+ {
+ coeff= 1.0 - d;
+ if (coeff<0) coeff=0;
+ }
+ else if (flags & SWS_SPLINE)
+ {
+ double p=-2.196152422706632;
+ coeff = getSplineCoeff(1.0, 0.0, p, -p-1.0, d);
+ }
+ else {
+ coeff= 0.0; //GCC warning killer
+ ASSERT(0)
+ }
+ return coeff;
+}
+
static inline int 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,
double param[2])
@@ -1003,6 +1074,7 @@ static inline int initFilter(int16_t **outFilter, int16_t
**filterPos, int *outF
for (j=0; j<filterSize; j++)
{
double d= FFABS(xx - xDstInSrc)/filterSizeInSrc*sizeFactor;
+#if 0
double coeff;
if (flags & SWS_BICUBIC)
{
@@ -1072,6 +1144,8 @@ static inline int initFilter(int16_t **outFilter, int16_t
**filterPos, int *outF
}
filter[i*filterSize + j]= coeff;
+#endif
+ filter[i*filterSize + j]= getcoeff( flags, param, d, xInc1);
xx++;
}
xDstInSrc+= xInc1;
_______________________________________________
FFmpeg-soc mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-soc