diff --git a/detect.cc b/detect.cc index 40984d4..8628718 100644 --- a/detect.cc +++ b/detect.cc @@ -1,5 +1,7 @@ +#include +#include #include #include #include "config.h" @@ -240,6 +242,14 @@ void Detect::InputDetect(int *posx, int *posy) { #endif } +inline float calc_vector(uint8_t a1, uint8_t a2, uint8_t b1, uint8_t b2, uint8_t c1, uint8_t c2, uint8_t d1, uint8_t d2) { + return (float) (a1 * a2 + b1 * b2 + c1 * c2 + d1 * d2); + // __m64 m1 = _mm_set_pi16 (a1, b1, c1, d1 ); + // __m64 m2 = _mm_set_pi16 (a2, b2, c2, d2 ); + // __m64 m3 = _mm_madd_pi16 (m1, m2); + // uint32_t *data = (uint32_t *) &m3; + // return (float) (data[0] + data[1]); +} #define OBJSIZE 50 #define MAXSHIFT 20 @@ -304,7 +314,12 @@ void Detect::InputDetectCrossC(int *posx, int *posy) { for (x = 0; x < OBJSIZE; x++, oldi += 3, ini += 3, oldx++, inx++) { if (oldx >= 0 && oldy >= 0 && oldx < oldFrame.w && oldy <= oldFrame.h && inx >= 0 && inx < inFrame.w && iny >= 0 && iny < inFrame.h) { - f += (float)(pxo[oldi+0])*(float)(pxi[ini+0]); + //f += (float)(pxo[oldi+0])*(float)(pxi[ini+0]); + f += calc_vector( pxo[oldi+0], pxi[ini+0], + pxo[oldi+3], pxi[ini+3], + pxo[oldi+6], pxi[ini+6], + pxo[oldi+9], pxi[ini+9]); + x+=3; oldi += 9; ini += 9; oldx+=3; inx+=3; } } }