fix bug 3733 for imgproc/filter.cpp

pull/3076/head
Aleksandr Petrikov 11 years ago committed by Vadim Pisarevsky
parent a15db2d9cf
commit 0a531815c5
  1. 45
      modules/imgproc/src/filter.cpp

@ -2635,9 +2635,9 @@ struct SymmColumnSmallFilter : public SymmColumnFilter<CastOp, VecOp>
const ST* ky = (const ST*)this->kernel.data + ksize2; const ST* ky = (const ST*)this->kernel.data + ksize2;
int i; int i;
bool symmetrical = (this->symmetryType & KERNEL_SYMMETRICAL) != 0; bool symmetrical = (this->symmetryType & KERNEL_SYMMETRICAL) != 0;
bool is_1_2_1 = ky[0] == 1 && ky[1] == 2; bool is_1_2_1 = ky[0] == 2 && ky[1] == 1;
bool is_1_m2_1 = ky[0] == 1 && ky[1] == -2; bool is_1_m2_1 = ky[0] == -2 && ky[1] == 1;
bool is_m1_0_1 = ky[1] == 1 || ky[1] == -1; bool is_m1_0_1 = (ky[1] == 1 || ky[1] == -1) && ky[1] == -ky[-1] && ky[0] == 0;
ST f0 = ky[0], f1 = ky[1]; ST f0 = ky[0], f1 = ky[1];
ST _delta = this->delta; ST _delta = this->delta;
CastOp castOp = this->castOp0; CastOp castOp = this->castOp0;
@ -2668,13 +2668,12 @@ struct SymmColumnSmallFilter : public SymmColumnFilter<CastOp, VecOp>
D[i+2] = castOp(s0); D[i+2] = castOp(s0);
D[i+3] = castOp(s1); D[i+3] = castOp(s1);
} }
#else #endif
for( ; i < width; i ++ ) for( ; i < width; i ++ )
{ {
ST s0 = S0[i] + S1[i]*2 + S2[i] + _delta; ST s0 = S0[i] + S1[i]*2 + S2[i] + _delta;
D[i] = castOp(s0); D[i] = castOp(s0);
} }
#endif
} }
else if( is_1_m2_1 ) else if( is_1_m2_1 )
{ {
@ -2691,13 +2690,12 @@ struct SymmColumnSmallFilter : public SymmColumnFilter<CastOp, VecOp>
D[i+2] = castOp(s0); D[i+2] = castOp(s0);
D[i+3] = castOp(s1); D[i+3] = castOp(s1);
} }
#else #endif
for( ; i < width; i ++ ) for( ; i < width; i ++ )
{ {
ST s0 = S0[i] - S1[i]*2 + S2[i] + _delta; ST s0 = S0[i] - S1[i]*2 + S2[i] + _delta;
D[i] = castOp(s0); D[i] = castOp(s0);
} }
#endif
} }
else else
{ {
@ -2714,13 +2712,12 @@ struct SymmColumnSmallFilter : public SymmColumnFilter<CastOp, VecOp>
D[i+2] = castOp(s0); D[i+2] = castOp(s0);
D[i+3] = castOp(s1); D[i+3] = castOp(s1);
} }
#else #endif
for( ; i < width; i ++ ) for( ; i < width; i ++ )
{ {
ST s0 = (S0[i] + S2[i])*f1 + S1[i]*f0 + _delta; ST s0 = (S0[i] + S2[i])*f1 + S1[i]*f0 + _delta;
D[i] = castOp(s0); D[i] = castOp(s0);
} }
#endif
} }
for( ; i < width; i++ ) for( ; i < width; i++ )
D[i] = castOp((S0[i] + S2[i])*f1 + S1[i]*f0 + _delta); D[i] = castOp((S0[i] + S2[i])*f1 + S1[i]*f0 + _delta);
@ -2744,17 +2741,14 @@ struct SymmColumnSmallFilter : public SymmColumnFilter<CastOp, VecOp>
D[i+2] = castOp(s0); D[i+2] = castOp(s0);
D[i+3] = castOp(s1); D[i+3] = castOp(s1);
} }
#else #endif
for( ; i < width; i ++ ) for( ; i < width; i ++ )
{ {
ST s0 = S2[i] - S0[i] + _delta; ST s0 = S2[i] - S0[i] + _delta;
D[i] = castOp(s0); D[i] = castOp(s0);
} }
#endif
if( f1 < 0 )
std::swap(S0, S2);
} }
else else if( ky[0] == 0 )
{ {
#if CV_ENABLE_UNROLLED #if CV_ENABLE_UNROLLED
for( ; i <= width - 4; i += 4 ) for( ; i <= width - 4; i += 4 )
@ -2770,10 +2764,29 @@ struct SymmColumnSmallFilter : public SymmColumnFilter<CastOp, VecOp>
D[i+3] = castOp(s1); D[i+3] = castOp(s1);
} }
#endif #endif
for( ; i < width; i++ )
D[i] = castOp((S2[i] - S0[i])*f1 + _delta);
}
else
{
#if CV_ENABLE_UNROLLED
for( ; i <= width - 4; i += 4 )
{
ST s0 = (S2[i] - S0[i])*f1 + S1[i]*f0 + _delta;
ST s1 = (S2[i+1] - S0[i+1])*f1 + S1[i+1]*f0 + _delta;
D[i] = castOp(s0);
D[i+1] = castOp(s1);
s0 = (S2[i+2] - S0[i+2])*f1 + S1[i+2]*f0 + _delta;
s1 = (S2[i+3] - S0[i+3])*f1 + S1[i+2]*f0 + _delta;
D[i+2] = castOp(s0);
D[i+3] = castOp(s1);
}
#endif
for( ; i < width; i++ )
D[i] = castOp((S2[i] - S0[i])*f1 + S1[i]*f0 + _delta);
} }
for( ; i < width; i++ )
D[i] = castOp((S2[i] - S0[i])*f1 + _delta);
} }
} }
} }

Loading…
Cancel
Save