Commit Graph

1523 Commits

Author SHA1 Message Date
arancormonk
493800a0f3 Fix NEON widening code to avoid using vsubl_u8 (which returns uint16x8_t) and instead zero-extend with vmovl_u8, reinterpret to int16x8_t, then subtract 127 with vsubq_s16. This should fix the type mismatch and produce correct signed results. Moved use_avx2, use_sse2, and use_ssse3 declarations inside the #if defined(__x86_64__) || defined(__i386__) block. 2025-09-05 19:21:57 -04:00
lwvmobile
c0b6f186bd Merge pull request #308 from arancormonk/perf/rtlsdr-demod-optimizations
RTL‑SDR demod overhaul: runtime SIMD, lock‑free ring, L/M resampler, power‑domain squelch, and DSP/perf fixes
2025-09-05 15:51:54 -04:00
arancormonk
8b423a2f42 rtl_sdr_fm: fix potential race condition, zero int all demod init funcs, add timeouts to prevent indefinite blocking, remove producer-side tail advancement, harden udp socket read loop 2025-09-04 19:11:25 -04:00
arancormonk
8ec385fdf2 ensure all old references of rms have been updated to pwr, we avoid sqrt calculations and squelch comparisons are using the same units with updated default level 2025-09-04 14:08:22 -04:00
arancormonk
da8b9b6116 rtl_sdr_fm: add additional bounds checks and cleanup extra line 2025-09-04 12:53:54 -04:00
arancormonk
a866d98e75 rtl_sdr_fm: comment cleanup 2025-09-04 12:38:41 -04:00
arancormonk
e094f95b03 rtl_sdr_fm: FLL rotator - improve sine/cos approximation 2025-09-04 10:20:39 -04:00
arancormonk
f052271a16 rtl_sdr_fm: fix mean_power - integer-only implementation 2025-09-04 10:13:05 -04:00
arancormonk
09bf040810 rtl_sdr_fm: fix low_pass_simple - normalize to avoid amplitude growth/clipping 2025-09-04 10:06:11 -04:00
arancormonk
48b032e47a rtl_sdr_fm: fix Gardner timing interpolation cost and gating 2025-09-04 10:01:17 -04:00
arancormonk
046846337a rtl_sdr_fm: fix half-band decimator - exploit symmetry/zeros and consider SIMD 2025-09-04 09:57:50 -04:00
arancormonk
836da1f556 rtl_sdr_fm: fix USB callback - avoid extra copy when enqueuing into input ring. 2025-09-04 09:48:17 -04:00
arancormonk
dd8620bc39 rtl_sdr_fm: remove per-sample memmove from resampler, use ring buffer. 2025-09-04 09:34:09 -04:00
arancormonk
283d000b59 rtl_sdr_fm: fix critical correctness bug: +1 DC bias in rotate+widen paths 2025-09-04 09:27:59 -04:00
arancormonk
5834127ff7 rtl_sdr_fm: fix rotate+widen tail handling (scalar/AVX2/NEON) to preserve 90° rotation and add SSSE3 rotate+widen with runtime dispatch on x86. Also include tmmintrin and clarify SSE2 fallback comment. 2025-09-03 23:33:32 -04:00
arancormonk
2ce089ccf8 rtl_sdr_fm: make SIMD runtime dispatch thread-safe with pthread_once and ensure AVX2/SSE2 paths compile by relying on function-level target attributes (remove AVX2/SSE2 guards). Gate NEON rotate to AArch64 (ARMv7 falls back to scalar) while retaining NEON widen for portability and performance. 2025-09-03 23:21:37 -04:00
arancormonk
4e64ef1c11 rtl_sdr_fm: add runtime SIMD dispatch for widen/rotate paths, selecting AVX2/SSE2/NEON via CPUID/XGETBV (x86) or getauxval (ARM) with scalar fallbacks. Replace compile-time guards with lazy-initialized function-pointer wrappers so binaries run optimally across CPUs without changing call sites. 2025-09-03 23:06:55 -04:00
arancormonk
c764cf0eda rtl_sdr_fm: replace USB→demod double-buffer/condvar handoff with a lock-free SPSC ring; enqueue widened blocks and drop oldest on overflow to keep the callback non-blocking. Demod now reads ring blocks; ring is initialized/cleaned up, reducing wakeups and latency. 2025-09-03 22:45:18 -04:00
arancormonk
8b4fa81711 rtl_sdr_fm: consume HB cascade output in-place to avoid the final memcpy. Track the current buffer and assign lowpassed to the last stage’s output, preserving correctness while reducing memory traffic. 2025-09-03 22:38:50 -04:00
arancormonk
106aae1814 rtl_sdr_fm: fuse interleaved complex half-band decimation to avoid deinterleave/reinterleave in full_demod, reducing memory traffic and copies. Maintain per‑stage histories and equivalent output while improving throughput. 2025-09-03 22:35:34 -04:00
arancormonk
391048a45a rtl_sdr_fm: vectorize rotate+widen path: add AVX2/NEON implementations for widen_rotate90_u8_to_s16_bias127 with scalar tail fallback. This applies the 90° rotation and bias-127 widening in vectors to reduce callback CPU without changing behavior. 2025-09-03 22:23:05 -04:00
arancormonk
1b9c3aa659 rtl_sdr_fm: add residual-CFO FLL and optional Gardner timing correction before discriminator (TED disabled by default and applied only to non-FM unless forced), with linear interpolation, nominal 1/sps advance, and env-tunable gains. 2025-09-03 22:18:20 -04:00
arancormonk
e9b12b8bc6 rtl_sdr_fm: add polyphase rational resampler (L/M) enabled by default at 48 kHz (override via DSD_FME_RESAMP), integrate post-demod and update output.rate while keeping legacy upsampler as fallback. Implement tap design with L-phase gain compensation. 2025-09-03 22:02:19 -04:00
arancormonk
9e9ae95219 rtl_sdr_fm: use fast atan2 discriminator for analog mode to reduce quantization noise 2025-09-03 21:33:04 -04:00
arancormonk
86d91512bb rtl_sdr_fm: add AVX2 widening, optional combined rotate+widen, and fixed‑point linear upsampler with env flags; preserve legacy behavior by default. Fix decoding by matching legacy upsample length (NM) with tail fill and reproducing unsigned rotate semantics. 2025-09-03 21:20:41 -04:00
arancormonk
0b00832b1f rtl_sdr_fm: enable env-gated intra-block multithreading with a tiny 2-thread pool and preallocated buffers. Parallelize HB I/Q decimation and linear upsampler; add debug log when enabled. 2025-09-03 20:52:06 -04:00
arancormonk
2655fccdea rtl_sdr_fm: ring signaling and atomic annotations 2025-09-03 20:30:32 -04:00
arancormonk
ac8f17bf20 rtl_sdr_fm: guard and document bandwidth_multiplier behavior 2025-09-03 20:23:52 -04:00
arancormonk
0cb38d2c25 rtl_sdr_fm: SIMD optimize USB byte→int16 widening in callback 2025-09-03 20:20:43 -04:00
arancormonk
6fc327c3b6 rtl_sdr_fm: avoid sqrt in RMS utility (use power-domain) 2025-09-03 20:15:27 -04:00
arancormonk
00e7c51a21 rtl_sdr_fm: add a light post-demod audio low-pass filter 2025-09-03 19:19:25 -04:00
arancormonk
e2402d0328 rtl_sdr_fm: correct deemphasis coefficient derivation and make it configurable 2025-09-03 19:08:22 -04:00
arancormonk
402cef34a9 rtl_sdr_fm: improve decimation filters (half-band FIR cascade) 2025-09-03 18:53:44 -04:00
arancormonk
29be104345 rtl_sdr_fm: replace sample duplication with simple resampling (linear interpolation) 2025-09-03 18:30:38 -04:00
arancormonk
f3ec024000 rtl_sdr_fm: replace DC block with leaky integrator high-pass (IIR) 2025-09-03 18:18:00 -04:00
arancormonk
412a4dc3b1 rtl_sdr_fm: add saturating arithmetic for decimation and volume scaling 2025-09-03 18:05:28 -04:00
arancormonk
2eedcc125b rtl_sdr_fm: fix deemphasis state race 2025-09-03 18:01:06 -04:00
arancormonk
9b399f31da rtl_sdr_fm: enable vectorization and alignment for DSP arrays 2025-09-03 16:25:15 -04:00
arancormonk
2ec3f9a263 rtl_sdr_fm: hoist divisions and use integer scalers in hot loops 2025-09-03 16:14:26 -04:00
arancormonk
0decc5934c rtl_sdr_fm: add batch operations and thread scheduling 2025-09-03 15:58:33 -04:00
arancormonk
7dd9cd7566 rtl_sdr_fm: add batched consumer API 2025-09-03 15:51:45 -04:00
arancormonk
30766b34bd rtl_sdr_fm: fix timespec normalization in timed wait 2025-09-03 15:21:50 -04:00
arancormonk
e700e418be rtl_sdr_fm: make RMS squelch incremental and decimated 2025-09-03 15:17:07 -04:00
arancormonk
c6d3e4cea0 rtl_sdr_fm: removed the obsolete rwlock and lock sites 2025-09-03 15:08:19 -04:00
arancormonk
62a9372d61 rtl_sdr: make async buffer params explicit and safe 2025-09-03 15:03:38 -04:00
arancormonk
cc200ea82c rtl_sdr: make RMS squelch sqrt-free 2025-09-03 14:48:33 -04:00
arancormonk
03c6b28de3 rtl_sdr_fm: initialize async buffer length and consider buffer count 2025-09-03 14:36:26 -04:00
arancormonk
3fe14f3b1d rtl_sdr_fm: double-buffer the I/Q handoff and remove memcpy/locks between callback and demod 2025-09-03 14:30:32 -04:00
arancormonk
3adcf5f449 rtl_sdr_fm: replace std::queue + locks with a single-producer single-consumer ring buffer 2025-09-03 13:21:47 -04:00
arancormonk
b81e1e6d22 rtl_sdr_fm: fix atan2/LUT discriminator — use precise π, quadrant-correct LUT saturation, clamp ±π at wrap, and mutex-protect LUT free. 2025-09-03 10:38:52 -04:00