#include "stdafx.h" #include "math.h" #include "findperi.h" static const int samplesize=30; static const int thredthold=800; static double vectorangle(int size, unsigned char * a, unsigned char * b) { double sa,sb,sab; sa=0; sb=0; sab=0; for(int i=0; ithredthold) return s; } return s; } int findt::ismatch(int ib, int n) { if(n+2*samplesize>buffersize) return 0; int mv,mv2; mv = matchvalue(ib, n); if(mv > thredthold) return 0; int k; k=0; while(1) { if(n+k+1+samplesize >= buffersize) return 0; mv2 = matchvalue(ib, n+k+1); if(mv2 >= mv) break; mv = mv2; k++; } k = n+k; mv = matchvalue(ib, k+(k-ib)); if(mv > thredthold) return 0; period = k-ib; if(vectorangle(k-ib,buffer+ib,buffer+k)<0.9) return 0; return period; } static int vmax(unsigned char * buf) { int smax=0; for(int i=0; i