Browse Source

fix synchro code

tags/v1.2
Thierry Leconte 21 years ago
parent
commit
0bcf750a58
2 changed files with 16 additions and 30 deletions
  1. +9
    -10
      dsp.c
  2. +7
    -20
      filtercoeff.h

+ 9
- 10
dsp.c View File

@@ -139,7 +139,7 @@ static float pixels[PixelLine+SyncFilterLen];
static int npv=0; static int npv=0;
static int synced=0; static int synced=0;
static double max=0.0; static double max=0.0;
float corr,qcorr;
float corr,scorr;
double ph; double ph;
int n,res; int n,res;
@@ -153,18 +153,16 @@ int n,res;
return(0); 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) { if(corr < 0.75*max) {
synced=0; synced=0;
FreqLine=1.0; FreqLine=1.0;
} }
if(ph >=1.0 || ph <= -1.0) {
synced=0;
FreqLine=1.0;
}
max=corr;
if(synced<8) { if(synced<8) {
int shift,mshift; int shift,mshift;
@@ -176,11 +174,12 @@ int n,res;
return(0); return(0);
} }
/* lookup sync start */
mshift=0; mshift=0;
for(shift=1;shift<PixelLine;shift++) { for(shift=1;shift<PixelLine;shift++) {
double corr; double corr;
corr=fir(&(pixelv[shift]),ISync,SyncFilterLen);
corr=fir(&(pixelv[shift]),Sync,SyncFilterLen);
if(corr>max) { if(corr>max) {
mshift=shift; mshift=shift;
max=corr; max=corr;


+ 7
- 20
filtercoeff.h View File

@@ -102,28 +102,15 @@ float Qcoeff[151] = {
4.4785330284e-04,-1.8397163024e-04, 4.2794269223e-04 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 #define RSFilterLen 1591
static float rsfilter[RSFilterLen] = { static float rsfilter[RSFilterLen] = {
0.0,3.7950625746e-07, 7.6001859743e-07, 1.1415897914e-06, 0.0,3.7950625746e-07, 7.6001859743e-07, 1.1415897914e-06,


Loading…
Cancel
Save