kopia lustrzana https://github.com/windytan/slowrx
store less data from sync signal
rodzic
9cecba8a35
commit
248c424391
30
sync.c
30
sync.c
|
@ -27,10 +27,8 @@ guint FindSync (guint Length, guchar Mode, guint Rate, int *Skip) {
|
|||
gboolean SyncImg[700][630];
|
||||
double NextImgSample, t=0, slantAngle;
|
||||
|
||||
printf("len %d\n",Length);
|
||||
|
||||
// Repeat until slant < 0.5° or until we give up
|
||||
while (1) {
|
||||
while (TRUE) {
|
||||
TotPix = LineWidth/2; // Start at the middle of the picture
|
||||
NextImgSample = 0;
|
||||
t = 0;
|
||||
|
@ -39,26 +37,12 @@ guint FindSync (guint Length, guchar Mode, guint Rate, int *Skip) {
|
|||
|
||||
memset(SyncImg, FALSE, sizeof(SyncImg[0][0]) * 700 * 630);
|
||||
|
||||
// Draw the sync signal into memory
|
||||
for (s = 0; s < Length; s++) {
|
||||
// Draw the 2D sync signal at current rate
|
||||
|
||||
// t keeps track of time in seconds
|
||||
t += 1.0/Rate;
|
||||
|
||||
if (t >= NextImgSample) {
|
||||
|
||||
SyncImg[x][y] = HasSync[s];
|
||||
|
||||
if (y > maxsy) maxsy = y;
|
||||
|
||||
TotPix++;
|
||||
x++;
|
||||
if (x >= LineWidth) {
|
||||
y++;
|
||||
x=0;
|
||||
}
|
||||
|
||||
NextImgSample += ModeSpec[Mode].LineLen / (1.0 * LineWidth);
|
||||
for (y=0; y<ModeSpec[Mode].ImgHeight; y++) {
|
||||
for (x=0; x<LineWidth; x++) {
|
||||
t = y * ModeSpec[Mode].LineLen + 1.0*x/LineWidth * ModeSpec[Mode].LineLen;
|
||||
SyncImg[x][y] = HasSync[ (int)(t / 1.5e-3 * Rate/44100) ];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -69,7 +53,7 @@ guint FindSync (guint Length, guchar Mode, guint Rate, int *Skip) {
|
|||
memset(lines, 0, sizeof(lines[0][0]) * (MAXSLANT-MINSLANT)*2 * 600);
|
||||
|
||||
// Find white pixels
|
||||
for (cy = 0; cy < TotPix / LineWidth; cy++) {
|
||||
for (cy = 0; cy < ModeSpec[Mode].ImgHeight; cy++) {
|
||||
for (cx = 0; cx < LineWidth; cx++) {
|
||||
if (SyncImg[cx][cy]) {
|
||||
|
||||
|
|
19
video.c
19
video.c
|
@ -20,6 +20,7 @@ gboolean GetVideo(guchar Mode, guint Rate, int Skip, gboolean Redraw) {
|
|||
guint MaxBin = 0;
|
||||
guint VideoPlusNoiseBins=0, ReceiverBins=0, NoiseOnlyBins=0;
|
||||
guint n=0;
|
||||
guint SyncSample;
|
||||
int i=0, j=0,TargetBin=0;
|
||||
int Length=0, Sample=0;
|
||||
int FFTLen=1024, WinLength=0;
|
||||
|
@ -38,7 +39,6 @@ gboolean GetVideo(guchar Mode, guint Rate, int Skip, gboolean Redraw) {
|
|||
double ChanStart[4] = {0}, ChanLen[4] = {0};
|
||||
guchar Lum=0, Image[800][616][3] = {{{0}}};
|
||||
guchar Channel = 0;
|
||||
gboolean PrevHasSync;
|
||||
|
||||
// Initialize Hann windows of different lengths
|
||||
for (j = 0; j < 7; j++)
|
||||
|
@ -101,9 +101,7 @@ gboolean GetVideo(guchar Mode, guint Rate, int Skip, gboolean Redraw) {
|
|||
Length = ModeSpec[Mode].LineLen * ModeSpec[Mode].ImgHeight * 44100;
|
||||
|
||||
Abort = FALSE;
|
||||
PrevHasSync = FALSE;
|
||||
|
||||
printf("pcmpointer %d\n",PcmPointer);
|
||||
SyncSample = 0;
|
||||
|
||||
// Loop through signal
|
||||
for (Sample = 0; Sample < Length; Sample++) {
|
||||
|
@ -136,7 +134,8 @@ gboolean GetVideo(guchar Mode, guint Rate, int Skip, gboolean Redraw) {
|
|||
|
||||
memset(in, 0, sizeof(in[0]) *FFTLen);
|
||||
memset(out, 0, sizeof(out[0])*FFTLen);
|
||||
|
||||
|
||||
// Hann window
|
||||
for (i = 0; i < 64; i++) in[i] = PcmBuffer[PcmPointer+i-32] / 32768.0 * Hann[0][i];
|
||||
|
||||
fftw_execute(Plan1024);
|
||||
|
@ -151,15 +150,12 @@ gboolean GetVideo(guchar Mode, guint Rate, int Skip, gboolean Redraw) {
|
|||
|
||||
// If there is more than twice the amount of power per Hz in the
|
||||
// sync band than in the rest of the band, we have a sync signal here
|
||||
if (Psync > 2*Praw) HasSync[Sample] = TRUE;
|
||||
else HasSync[Sample] = FALSE;
|
||||
|
||||
PrevHasSync = HasSync[Sample];
|
||||
if (Psync > 2*Praw) HasSync[SyncSample] = TRUE;
|
||||
else HasSync[SyncSample] = FALSE;
|
||||
|
||||
NextSyncTime += 1.5e-3;
|
||||
SyncSample ++;
|
||||
|
||||
} else {
|
||||
HasSync[Sample] = PrevHasSync;
|
||||
}
|
||||
|
||||
|
||||
|
@ -230,6 +226,7 @@ gboolean GetVideo(guchar Mode, guint Rate, int Skip, gboolean Redraw) {
|
|||
}
|
||||
|
||||
// Halve the window size for M2 and S2, except under excellent or hopeless SNR
|
||||
// FIXME: nonsensic hack
|
||||
if ( (Mode == M2 || Mode == S2) && WinLength > 64 && WinLength < 512) {
|
||||
WinLength /= 2;
|
||||
WinIdx --;
|
||||
|
|
Ładowanie…
Reference in New Issue