kopia lustrzana https://github.com/keenerd/rtl-sdr
rtl_fm: remove unused resamplers
rodzic
6bcea884a7
commit
90706d4098
65
src/rtl_fm.c
65
src/rtl_fm.c
|
@ -763,71 +763,6 @@ int squelch_to_rms(int db, struct dongle_state *dongle, struct demod_state *demo
|
|||
return (int)linear + 1;
|
||||
}
|
||||
|
||||
void arbitrary_upsample(int16_t *buf1, int16_t *buf2, int len1, int len2)
|
||||
/* linear interpolation, len1 < len2 */
|
||||
{
|
||||
int i = 1;
|
||||
int j = 0;
|
||||
int tick = 0;
|
||||
double frac; // use integers...
|
||||
while (j < len2) {
|
||||
frac = (double)tick / (double)len2;
|
||||
buf2[j] = (int16_t)(buf1[i-1]*(1-frac) + buf1[i]*frac);
|
||||
j++;
|
||||
tick += len1;
|
||||
if (tick > len2) {
|
||||
tick -= len2;
|
||||
i++;
|
||||
}
|
||||
if (i >= len1) {
|
||||
i = len1 - 1;
|
||||
tick = len2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void arbitrary_downsample(int16_t *buf1, int16_t *buf2, int len1, int len2)
|
||||
/* fractional boxcar lowpass, len1 > len2 */
|
||||
{
|
||||
int i = 1;
|
||||
int j = 0;
|
||||
int tick = 0;
|
||||
double remainder = 0;
|
||||
double frac; // use integers...
|
||||
buf2[0] = 0;
|
||||
while (j < len2) {
|
||||
frac = 1.0;
|
||||
if ((tick + len2) > len1) {
|
||||
frac = (double)(len1 - tick) / (double)len2;}
|
||||
buf2[j] += (int16_t)((double)buf1[i] * frac + remainder);
|
||||
remainder = (double)buf1[i] * (1.0-frac);
|
||||
tick += len2;
|
||||
i++;
|
||||
if (tick > len1) {
|
||||
j++;
|
||||
buf2[j] = 0;
|
||||
tick -= len1;
|
||||
}
|
||||
if (i >= len1) {
|
||||
i = len1 - 1;
|
||||
tick = len1;
|
||||
}
|
||||
}
|
||||
for (j=0; j<len2; j++) {
|
||||
buf2[j] = buf2[j] * len2 / len1;}
|
||||
}
|
||||
|
||||
void arbitrary_resample(int16_t *buf1, int16_t *buf2, int len1, int len2)
|
||||
/* up to you to calculate lengths and make sure it does not go OOB
|
||||
* okay for buffers to overlap, if you are downsampling */
|
||||
{
|
||||
if (len1 < len2) {
|
||||
arbitrary_upsample(buf1, buf2, len1, len2);
|
||||
} else {
|
||||
arbitrary_downsample(buf1, buf2, len1, len2);
|
||||
}
|
||||
}
|
||||
|
||||
void software_agc(struct demod_state *d)
|
||||
/* ignores complex pairs, indirectly calculates power squelching */
|
||||
{
|
||||
|
|
Ładowanie…
Reference in New Issue