diff --git a/dsp.c b/dsp.c index 3cc8a83..52b9b83 100755 --- a/dsp.c +++ b/dsp.c @@ -139,7 +139,7 @@ static float pixels[PixelLine+SyncFilterLen]; static int npv=0; static int synced=0; static double max=0.0; -float corr,qcorr; +float corr,scorr; double ph; int n,res; @@ -153,18 +153,16 @@ int n,res; return(0); } - iqfir(pixelv,ISync,QSync,SyncFilterLen,&corr,&qcorr); - ph=atan2((double)qcorr,(double)corr)/M_PI*2.0; - max=corr; - FreqLine=(double)(PixelLine-SyncFilterLen-ph)/(double)(PixelLine-SyncFilterLen); + /* test sync */ + corr=fir(pixelv,Sync,SyncFilterLen); + scorr=fir(&(pixelv[1]),Sync,SyncFilterLen); + FreqLine=1.0-scorr/corr/PixelLine/4.0; + if(corr < 0.75*max) { synced=0; FreqLine=1.0; } - if(ph >=1.0 || ph <= -1.0) { - synced=0; - FreqLine=1.0; - } + max=corr; if(synced<8) { int shift,mshift; @@ -176,11 +174,12 @@ int n,res; return(0); } + /* lookup sync start */ mshift=0; for(shift=1;shiftmax) { mshift=shift; max=corr; diff --git a/filtercoeff.h b/filtercoeff.h index 1e3b2b9..2747a29 100755 --- a/filtercoeff.h +++ b/filtercoeff.h @@ -102,28 +102,15 @@ float Qcoeff[151] = { 4.4785330284e-04,-1.8397163024e-04, 4.2794269223e-04 }; -#define SyncFilterLen 30 -static float ISync[SyncFilterLen]={ - -3.125e-02,-3.125e-02,3.571428e-02,3.571428e-02, - -3.125e-02,-3.125e-02,3.571428e-02,3.571428e-02, - -3.125e-02,-3.125e-02,3.571428e-02,3.571428e-02, - -3.125e-02,-3.125e-02,3.571428e-02,3.571428e-02, - -3.125e-02,-3.125e-02,3.571428e-02,3.571428e-02, - -3.125e-02,-3.125e-02,3.571428e-02,3.571428e-02, - -3.125e-02,-3.125e-02,3.571428e-02,3.571428e-02, - -3.125e-02,-3.125e-02 -}; -static float QSync[SyncFilterLen]={ - -3.125e-02,-3.125e-02,-3.125e-02,3.571428e-02,3.571428e-02, - -3.125e-02,-3.125e-02,3.571428e-02,3.571428e-02, - -3.125e-02,-3.125e-02,3.571428e-02,3.571428e-02, - -3.125e-02,-3.125e-02,3.571428e-02,3.571428e-02, - -3.125e-02,-3.125e-02,3.571428e-02,3.571428e-02, - -3.125e-02,-3.125e-02,3.571428e-02,3.571428e-02, - -3.125e-02,-3.125e-02,3.571428e-02,3.571428e-02, - -3.125e-02 +#define SyncFilterLen 34 +static float Sync[SyncFilterLen]={ + -14,-14,-14,-14, + 20,20,-14,-14,20,20,-14,-14,20,20,-14,-14, + 20,20,-14,-14,20,20,-14,-14,20,20,-14,-14, + 20,20,-14,-14,-14,-14 }; + #define RSFilterLen 1591 static float rsfilter[RSFilterLen] = { 0.0,3.7950625746e-07, 7.6001859743e-07, 1.1415897914e-06,