static inline Fixpt dbl2fixpt(double x) { return x * int2fixpt(1); }
static inline double fixpt2dbl(Fixpt x) { return x / (1.0*int2fixpt(1)); }
static inline Fixpt fixpt_mul(Fixpt a, Fixpt b) {
- return (a*b + dbl2fixpt(0.5)) >> FIXPT_SHIFT;
+ return (a*b + dbl2fixpt(0.5)) / int2fixpt(1);
}
#define MFP(v) fprintf(stderr," %s=%lx=%f", #v,(v),fixpt2dbl((v)))
Fixpt alpha_mean= fixpt_mul(alpha_total, one_third);
Fixpt thresh= dbl2fixpt(1.5/AAMAXVAL);
- Fixpt alpha_min= alpha_mean - thresh;
- Fixpt alpha_max= alpha_mean + thresh;
+ Fixpt alpha_min= alpha_mean - thresh*2;
+ Fixpt alpha_max= alpha_mean + thresh*2;
for (i=0; i<3; i++)
MUST( alpha_min <= alpha[i] && alpha[i] <= alpha_max,
MP(p);
MRGB(here);MRGB(aa_background);MRGB(aa_foreground);
- MFP(aa_alpha_mean_max);
- MFP(alpha_min); MI(i);MFP(alpha[i]);MFP(alpha_max) );
+ MFP(aa_alpha_mean_max);MFP(thresh);MFP(alpha_mean);
+ MFP(alpha_min);MI(i);MFP(alpha[i]);MFP(alpha_max) );
- MUST( 0 <= alpha_mean && alpha_mean <= aa_alpha_mean_max,
+ MUST( -thresh <= alpha_mean && alpha_mean <= aa_alpha_mean_max + thresh,
MP(p);
MRGB(here);MRGB(aa_background);MRGB(aa_foreground);
- MFP(aa_alpha_mean_max);
+ MFP(aa_alpha_mean_max);MFP(thresh);
MFP(alpha_mean); MFP(alpha[0]);MFP(alpha[1]);MFP(alpha[2]); );
+ if (alpha_mean < 0) alpha_mean= 0;
+ if (alpha_mean > aa_alpha_mean_max) alpha_mean= aa_alpha_mean_max;
+
return alpha_mean;
}