-
Notifications
You must be signed in to change notification settings - Fork 1
/
F1Quiver_test_common_code.txt
181 lines (132 loc) · 3.5 KB
/
F1Quiver_test_common_code.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
// this code repeats. so will insert at appropriate place
// if ( nb = 8)
// {
// uint8_t * sp = (uint8_t *) srcp;
// uint8_t * dp = (uint8_t *) dstp;
// 8 bit samples
for( int r = d->row; r < d->row + d->nrows; r ++)
{
if (d->morph)
getVMorphInput(in, sp + r * pitch, d->nfft, wd, d->logLUT);
else
getVInput(in, sp + r * pitch, d->nfft, wd);
d->fftwf_execute_dft_r2c(d->pf, in, out);
// the following for power spectrum
// sum powerspectra
for(int i = 0; i < d->best / 2 + 1; i++)
{
powerspect[i] += out[i][0] * out[i][0] + out[i][1] * out[i][1];
}
}
// normalize
float pmax = 0;
for(int i = 0; i < d->best/2 + 1; i ++)
{
if ( pmax < powerspect[i])
pmax = powerspect[i];
}
// process the frame
for(int h = 0; h < ht ; h++)
{
if ( d->morph)
getVMorphInput(in, sp + h * pitch, d->best, wd, d->logLUT);
else
getVInput(in, sp + h * pitch, d->best, wd );
d->fftwf_execute_dft_r2c(d->pf, in, out);
ApplyFilter(out,d->FreqFilter, d->best /2 + 1);
d->fftwf_execute_dft_c2r(d->pin, out, in);
if( d->morph)
getVMorphOutput(in, dp + h * pitch, wd, max);
else
getVOutput(in, dp + h * pitch, wd, max);
}
// zero out left half of frame
for ( int h = 0; h < ht; h ++)
{
for ( int w = 0; w < wd /2; w++)
{
dp[ h * pitch + w] = 0;
}
}
int panelh= 100;
int pscale = 100;
if (ht < 220)
{
panelh = (ht - 20) / 2;
pscale = panelh;
}
// scale and display
if(pmax > 0)
{
for(int i = 0; i < wd / 2; i++)
{
//power spectrum
for (int h = 0; h < (powerspect[i] * pscale) / pmax; h ++)
{
dp[(2 * panelh + 20 - h) * pitch + i] = max; // normal scale
}
// exp gamma scale
for(int h = 0; h < pow(powerspect[i] / pmax, d->gamma) * pscale; h ++)
{
dp[(panelh - h) * pitch + i] = max; // gamma scale
}
// designed filter
dp[(panelh - (int)(pscale * d->FreqFilter[i] * d->nfft)) * pitch + i] = (max + max) / 3;
dp[(panelh + 1 - (int)(pscale * d->FreqFilter[i] * d->nfft)) * pitch + i] = (max + max) / 3;
}
}
for(int i = 0; i < NYQUIST; i ++)
{
int ws = (i * d->best) / (2*NYQUIST) ;
// display horizontal scale for freq
if((i % 100) == 0)
{
for(int h = 0; h < 10; h ++)
{
dp[(h + panelh + 5) * pitch + ws] = max;
}
}
else if((i % 50) == 0)
{
if(wd >= NYQUIST/20) // to ensure readability
{
for(int h = 0; h < 6; h ++)
{
dp[(h + panelh + 6) * pitch + ws] = (4 * max)/ 5;
}
}
}
else if((i % 10) == 0)
{
if(wd >= NYQUIST / 2)
{
for(int h = 0; h < 3; h ++)
{
dp[(h + panelh + 7) * pitch + ws] = (3* max)/4;
}
}
}
}
/*
for (int plane = 1; plane < fi->numPlanes; plane ++)
{
const uint8_t *srcp = vsapi->getReadPtr(src, plane);
int src_stride = vsapi->getStride(src, plane);
uint8_t *dstp = vsapi->getWritePtr(dst, plane);
int dst_stride = vsapi->getStride(dst, plane);
int ht = vsapi->getFrameHeight(src, plane);
int wd = vsapi->getFrameWidth(src, plane);
int pitch = dst_stride / fi->bytesPerSample;
// copy u & v of right half
vs_bitblt(dstp + wd/ 2, dst_stride, srcp+ wd / 2, src_stride, wd/2 * fi->bytesPerSample, ht);
// make left half of image grey
for (int y = 0; y < ht; y++)
{
for (int x = 0; x < wd / 2; x++)
{
dstp[x] = grey;
}
dstp += pitch;
}
}
*/