Repository navigation
Description
Note
Execution plan for the work scoped in #13 (feasibility, with prototype) and motivated by #10 (license strategy: delete RPSL libhelix_mp3). Implementation PRs land in FastLED/FastLED; this issue is the phase tracker and can be transferred there when work begins. Each phase has an explicit exit gate — no phase starts until the previous gate is green in CI.
Job: vendor minimp3 → optimize to Helix parity → SIMD past Helix → lock in as the only MP3 backend
End state: src/third_party/minimp3/ (CC0, fixed-point capable, SIMD-accelerated) is FastLED's only MP3 decoder; src/third_party/libhelix_mp3/ (RPSL/RCSL) is deleted; the decoder is "locked": golden-tested, fuzzed, memory- and cycle-budgeted in CI so it cannot silently regress.
Ground-truth budgets to beat (Helix, from the #13 audit):
| Metric | Helix baseline |
|---|---|
| Working RAM | ~24 KB heap (7 mallocs), tiny stack |
| Arithmetic | ~55–75k multiplies/frame; 64-bit MACs only in polyphase |
| Realtime record | ESP32 LX6/LX7, ESP32-C3, RP2040, Cortex-M3/M4 — proven |
| SIMD | none anywhere — this is how we beat it |
Phase 0 — Vendor & scaffold (no behavior change)
- Vendor
minimp3.h(+minimp3_ex.hif needed for tests only) intosrc/third_party/minimp3/following FastLED conventions:namespace fl { namespace third_party { … } }wrap,FL_NO_EXCEPT,MINIMP3_NO_STDIO, unity-build integration (_build.cpp.hpp→src/fl/build/third_party+.cpp). - Ship
LICENSE(CC0-1.0) in the component dir + third-party manifest entry + per-file markers per the universal-marker policy (Strategy: project-agnostic GPL/free-software compatibility exception #10). Record upstream commit SHA inPROVENANCE-style note. - Dual-backend scaffold:
src/fl/codec/mp3.hpublic API unchanged; backend selected at compile time —FASTLED_MP3_BACKEND_HELIX(default, unchanged) vsFASTLED_MP3_BACKEND_MINIMP3. The five-call Helix wrapper gets a sibling minimp3 wrapper (mp3dec_decode_framemaps 1:1; deriveMp3Info.versionfrom the header bytes sincemp3dec_frame_info_tlacks it). - Scratch off the stack immediately (prereq for everything): add
mp3dec_decode_frame_r(dec, scratch, …)taking caller-providedmp3dec_scratch_t(16.3 KB); wrapper owns it heap-side. Upstream-friendly patch, kept as a minimal diff file against pristine upstream. - Golden harness v1 (host): one test binary builds Helix + minimp3-float backends; corpus from Feasibility: MINIMP3_FIXED_POINT — CC0 fixed-point minimp3 mode, golden-tested vs float, to replace RPSL libhelix_mp3 #13 (ISO 11172-4/13818-4 vectors, LAME synthetics incl. −60 dBFS sine, joint/intensity stereo, MPEG-2/2.5 low rates, free-format, VBR reservoir stress, resync garbage). Assert identical frame acceptance/sample counts between backends; PCM compared to ISO reference (both must pass limited-accuracy floor) and to each other (report-only PSNR — Helix vs minimp3 are different decoders; the hard golden gate arrives in Phase 3 as fixed-vs-float within minimp3).
Exit gate G0: minimp3-float backend passes the full corpus behaviorally on host CI (Linux + Windows + macOS); public Mp3 API byte-compatible; Helix default untouched; no src/ build regression on any platform (compile-only matrix incl. AVR/WASM).
Phase 1 — Memory audit (native host)
Build the measurement rig before optimizing anything. All instruments run on host; each produces a line in a versioned ledger.
- Heap: route all codec allocations through an accounting allocator (
fl::hooks): bytes-current, bytes-peak, alloc-count, per-tag (decoder-state / scratch / stream-buffer). Cross-check withheaptrackorvalgrind --tool=massifin the Linux CI job. - Stack: three instruments — (1)
-fstack-usage+-Wframe-larger-than=on every codec TU (fails the build over budget); (2) watermark painting in the harness (fill a guard region with a pattern around the decode call, measure high-water); (3) static worst-depth estimate from.sufiles + call graph. Budget: ≤ 2 KB stack per decode call (everything big must be in owned state/scratch). - Static/flash:
nm --size-sort/sizeon the codec object; table ledger (every const table, bytes, which stage). Fixed-point tables added in Phase 3 must be itemized here. - Ledger:
codec_memory_ledger.mdchecked in, machine-parsed in CI; a PR that regresses any figure > 2% fails unless the ledger is deliberately updated in the same PR (fail-closed, same philosophy as the license tooling). - Record Helix's numbers with the identical rig (it's in-tree — same allocator hooks, same watermarking) so parity claims are apples-to-apples.
Targets: working RAM (persistent + scratch + stream buffer) ≤ 24 KB (parity), stretch ≤ 20 KB; flash tables ≤ Helix's table footprint + 20%.
Exit gate G1: ledger populated for Helix and minimp3-float; CI regression gate live; scratch-off-stack verified by watermark (< 2 KB stack).
Phase 2 — CPU profiling audit (native host)
Host cycles don't predict MCU cycles — so the rig measures three tiers, from portable to µarch-specific:
- Tier 1 — arithmetic-op ledger (the MCU-honest metric): instrument the multiply primitives (
MULSHIFT32, 64-bit MAC, float mul in the float build) with audit-build counters. Decode the corpus; report exact multiplies/frame and MACs/frame per stage, for Helix and minimp3 alike. This is the metric parity is defined on (Feasibility: MINIMP3_FIXED_POINT — CC0 fixed-point minimp3 mode, golden-tested vs float, to replace RPSL libhelix_mp3 #13 projection: 55–75k/frame) and it is host-independent. - Tier 2 — host attribution:
perf stat(cycles, instructions, IPC, branch misses) +valgrind --tool=callgrindper-function attribution; per-stage wall-time via theMINIMP3_STAGE_DUMPhooks' timer variant. Pinned governor, deterministic corpus, N=30 runs, report medians. Trend file (codec_cpu_trend.json) tracked in CI; ±5% regression gate. - Tier 3 — codegen inspection for MCU ISAs: cross-compile the codec TU with
-Osforxtensa-esp32-elf,riscv32-esp-elf,arm-none-eabi -mcpu=cortex-m0plusand-mcpu=cortex-m4;objdumpthe inner loops (polyphase, DCT32); record inner-loop instruction counts in the ledger. Catches "host looked fine, M0+ emits a 6-instruction libcall per MAC" early — no hardware needed. - Baseline all three tiers for Helix with the same rig.
Exit gate G2: all three tiers automated in CI; Helix baseline recorded; minimp3-float baseline recorded (expect it to lose badly — that's the point of the ledger).
Phase 3 — Fixed-point conversion to parity (the #13 staged plan, run under the audit rigs)
Stage order and design per #13 (synthesis back-end → IMDCT/antialias → Huffman/dequant/scalefactors → stereo + guard-bit tracking end-to-end; MINIMP3_ONLY_MP3 for v1). Clean-room rules from #13 §Clean-room apply (Helix = ideas only; tables regenerated from ISO formulas; generator scripts committed).
- Golden gate hardens: fixed-vs-float within minimp3 — PSNR ≥ 90 dB and ≤ 8 LSB on every corpus file; −60 dB signal-relative gate ≥ 55 dB; per-stage
MINIMP3_STAGE_DUMPepsilons; differential fuzz (both modes agree accept/reject + PCM, ASan/UBSan clean). - Each converted stage must land with: golden green, memory ledger delta itemized, op-ledger delta itemized.
- Scalar optimization pass to close any gap to Helix parity: early-terminating polyphase multiplies (Helix's pre-shifted-coefficient concept), table layout for cache/flash-line locality, sync-scan cost reduction, buffer reuse between granules.
Exit gate G3 ("Helix parity"): on the op-ledger, multiplies/frame ≤ 1.1× Helix; working RAM ≤ 24 KB; stack ≤ 2 KB; all golden + fuzz gates green; Tier-3 inner-loop instruction counts within 1.2× of Helix's on all four ISAs. One on-target spot-check (ESP32 + RP2040 cycles/frame) to validate that the host proxies track reality — the only non-host step in the audit plan, run once at this gate.
Phase 4 — SIMD: beat Helix
Helix has zero SIMD — this is the phase that makes replacement strictly better, not just license-clean. Integer SIMD is bit-exact vs scalar fixed-point, so the golden gate here is exact equality, the strongest possible lock.
- Host lanes first (prove the pattern where profiling is easy): SSE2 and NEON int32 paths for the dominant costs — polyphase (~37k MACs/frame), DCT32, IMDCT butterflies — following minimp3's existing float-SIMD scaffolding style (
MINIMP3_NO_SIMDopt-out preserved). - Embedded flagship — ESP32-S3 PIE (128-bit vector unit): polyphase + DCT32 kernels via esp-dsp-style intrinsics/asm, guarded by chip detect at compile time.
- Optional stretch: Cortex-M4/M7 DSP extension scheduling (
SMULL/SMLALpipelines; evaluate whether dual-16SMLADfits anywhere without precision loss — likely not for Q25 data; document the finding either way). - Every SIMD kernel: bit-exact vs scalar fixed on the full corpus (exact-equality golden), covered by the differential fuzzer, and toggleable at compile time.
Exit gate G4 ("faster than Helix"): host cycles/frame ≥ 1.5× faster than Helix-scalar on x86-64 and Apple/ARM CI runners; ESP32-S3 ≥ 1.3× faster than Helix on-target; no target anywhere slower than the scalar fixed path; bit-exactness green.
Phase 5 — Swap & lock-in
- Flip the default:
FASTLED_MP3_BACKEND_MINIMP3becomes the default; Helix demoted toFASTLED_MP3_HELIX_LEGACYopt-in with a deprecation warning, for one minor release. - Run the Feasibility: MINIMP3_FIXED_POINT — CC0 fixed-point minimp3 mode, golden-tested vs float, to replace RPSL libhelix_mp3 #13 acceptance gate in full: golden suite green (ISO floor + internal PSNR gates), 72 h differential fuzz zero-divergence, on-target budgets (≤ 60% core on ESP32-C3@160 MHz and RP2040@133 MHz, ≤ 25% on ESP32@240 MHz for 44.1 kHz stereo 320 kbps), A/B listening sanity on demo content.
- Delete
src/third_party/libhelix_mp3/+ the.SsrcFilter line inlibrary.json; update third-party manifest, per-file markers, REUSE/SBOM output; note the removal in release notes ("FastLED no longer ships any RPSL/RCSL code"). - Lock the decoder in place: golden corpus + fuzz smoke + memory ledger + cpu trend + bit-exactness gates all become required PR checks for any file under
src/third_party/minimp3/orsrc/fl/codec/mp3*; CODEOWNERS on those paths; the vendored diff-against-upstream kept minimal and documented. - Upstream PR to lieff/minimp3 (
MINIMP3_FIXED_POINT+_rscratch API + SIMD lanes), CC0. If upstream is dormant, FastLED carries it in-tree as CC0 with the diff file as the contract. - Close the loop on the license side: update Strategy: project-agnostic GPL/free-software compatibility exception #10 (libhelix resolved — RPSL tree deleted), third-party audit row in the universal-marker migration, and
LEGAL-REVIEW.md's standing-exception note for libhelix.
Exit gate G5 (done): Helix tree deleted on main; all lock gates required in CI; one release shipped with minimp3 default and no regression reports on the audio-reactive examples.
Sequencing, effort, risks
Dependencies: G0→G1→G2 can overlap (rigs are independent); G3 depends on G1+G2 (can't claim parity without both ledgers); G4 depends on G3 (SIMD over the fixed kernels); G5 depends on G4.
Effort: #13 estimated ~6 pw for the conversion; the audit rigs add ~1.5 pw; SIMD ~2 pw (host lanes + S3); swap/lock ~0.5 pw → ~10 person-weeks + 2 contingency.
Top risks (carried from #13, plus new): (1) dynamic-range corners in the guard-bit budget → −60 dB gates + stage hooks; (2) M0+ 64-bit-MAC budget → Tier-3 codegen ledger catches it at G2/G3, measured 32-bit-MAC fallback ready; (3) S3 PIE toolchain friction (intrinsics maturity) → treat S3 SIMD as the G4 flagship but allow G4-host to gate independently if PIE slips one milestone; (4) upstream divergence — pristine-upstream + minimal-diff discipline keeps rebases cheap.
Activity
zackees commentedon Aug 25, 2026
Closing as out of scope for the reusable license-text repository. This execution plan changes FastLED source and dependencies, while this repository publishes general-purpose license text and legal research. The issue history remains available for migration to the FastLED software repository.
feat(mp3): fixed-point minimp3 DSP path (#4054) (#4105)
chore(mp3): make minimp3 the sole backend and delete libhelix (#4056) (…
zackees commentedon Sep 1, 2026
G5 has landed:
libhelix_mp3is deletedFastLED/FastLED#4056 merged as FastLED/FastLED@6990cdc3e4 (PR FastLED/FastLED#4112).
src/third_party/libhelix_mp3/is gone frommaster— 10,566 deletions — along with itsLICENSE.txt,RPSL.txtandRCSL.txt. FastLED's MP3 support is now entirely CC0 (minimp3), which is the outcome this tracker exists for.I am leaving this issue open. One named criterion was not delivered, and this tracker was closed prematurely once already. Details at the bottom.
Phases
Where the licensing argument now rests
The clean-room claim is no longer a promise, it is a property of the tree. Every fixed-point constant is generated from its ISO 11172-3 / 13818-3 formula by
ci/codec_tables/generate_minimp3_fixed_tables.pyand cross-checked against upstream minimp3's own CC0 float literals; Helix was never a source, not even for values that are mathematically forced. Deleting the tree is the proof — copied constants could not have been deleted.FASTLED.patchhad gone stale during the fixed-point work and is regenerated against upstreamea99364, verified by applying it to the pristine upstream file and diffing. Nothing in CI checks that, so PROVENANCE now carries a regeneration procedure that was run verbatim rather than written from memory.Deviations from the plan as written
Two of this plan's criteria were overridden by the maintainer, explicitly:
One criterion was not delivered and is not overridden:
Also outstanding: FastLED/FastLED#4109 (IMDCT twiddle/window vectorisation, capped near 2% and left scalar deliberately), FastLED/FastLED#4110 (the CPU trend still audits the float build; re-baselining it onto fixed point invalidates every host baseline at the moment it changes what is measured), and FastLED/FastLED#4106 (the stack watermark is not reproducible and is demoted to informational).
Why this stays open
The licensing objective — no RPSL/RCSL code in the tree — is met, and if that were this tracker's only content it would close today. But the plan above also commits to an ESP32-S3 PIE path that does not exist, and closing over an undelivered criterion is what went wrong here last time. Closing this is a maintainer call: either FastLED/FastLED#4108 lands, or the criterion is explicitly dropped and this closes with that recorded.
zackees commentedon Sep 1, 2026
The ESP32-S3 PIE criterion is settled, by measurement
I said above that this tracker should stay open because Phase 4's "embedded flagship — ESP32-S3 PIE" item was undelivered, and that closing over an undelivered criterion is what went wrong here once already. That item is now resolved as not achievable at any acceptable precision (FastLED/FastLED#4108), so it is not deferred work.
The instruction set does not have the primitive. The fixed-point pipeline needs a 32x32->64 widening signed multiply and a rounded narrowing shift. The ESP32-S3 PIE has neither: its multiplies are
EE.VMUL.S8/EE.VMUL.S16, QACC accumulates "16 8-bit or 8 16-bit MAC results", and an independent teardown names the missing essentials as "multiply with widening" and "right shift with narrowing". FastLED's ownsrc/platforms/esp/32/simd_xtensa.hpphad already reached the same conclusion in a different context — "operations without PIE equivalents (i32 arithmetic, float, shifts) use scalar fallback", with noee.*instruction anywhere in the file.Nor is this something minimp3 introduced. Helix needed the identical primitive:
MULSHIFT32is documented as "returns top 32 bits of 64-bit result" and lowers toimulon x86,smullon ARM andmulhon RISC-V, with a full 64-bitMADD64alongside it. Helix would not have used S3 PIE either. 32x32->64 is a property of fixed-point MP3 decoding, not of the decoder we chose.And the precision cost was measured, not estimated. The relevant bar is parity with Helix, not with minimp3's float build. Against the ISO limited-accuracy reference vector:
A 16-bit path costs ~79 dB, not the ~16 dB FastLED/FastLED#4055 estimated. That is 58 dB below Helix and 15 dB below the ISO floor -- it would fail compliance outright, not merely regress. Block floating point would beat the naive scheme but would have to recover about ten bits to reach parity, which is not an implementation-quality gap.
Worth recording that the shipping fixed-point decoder is 20.4 dB more accurate than the Helix it replaced, on the same rig and the same vector. The licensing change was not an accuracy trade.
Where that leaves this tracker
Every phase is closed, and the one criterion I was holding it open for is now closed on evidence rather than dropped for convenience:
Still open and genuinely outstanding, but none of them licensing-blocking: FastLED/FastLED#4109 (IMDCT twiddle vectorisation, measured at -2.34% instructions, in review), FastLED/FastLED#4110 (fixed-point CPU trend row, in review), FastLED/FastLED#4116 (the decoder sits at 94% of its 2 KiB stack budget; the fix is relocating inlined locals into the already-heap-allocated scratch arena).
The two criteria the maintainer explicitly overrode -- the one-minor-release compatibility window and the full #13 acceptance run -- remain overridden, quoted in my earlier comment.
My read is that this can close once FastLED/FastLED#4109 and FastLED/FastLED#4110 merge, with ESP32-P4 as the only thing that would legitimately reopen the PIE question, since its PIE is a different and larger instruction set. Still a maintainer call.
zackees commentedon Sep 2, 2026
Complete on FastLED master
The plan in this issue — vendor minimp3, optimise to Helix parity, delete libhelix_mp3 — is done, and FastLED/FastLED#4056 is closed.
Licence position.
origin/mastercontains zero files undersrc/third_party/libhelix_mp3/. minimp3 (CC0) is the sole MP3 backend and it is unconditional: there is noFASTLED_MP3_BACKEND_HELIXsymbol left, so there is not even a dormant code path. The only remaining occurrences of the string "helix" on master are comments about the retired baseline, the historical note inPROVENANCE.md, and references to SoundHelix — an unrelated test-audio website used by the audio examples.Not a capability regression. The parity gate this issue set was met and passed. On an ESP32-C6 the decode went from 142,647 µs to 39,385 µs — 72% — taking minimp3-fixed from 3.99× the Helix reference to 1.13×, with accuracy unchanged at 123.24 dB throughout (ISO floor 60 dB; Helix itself scores 102.87 dB). 83 ISO conformance vectors pass on the host and, bit-exactly, on riscv32 and arm.
Three disclosures, since this is a licence issue
A public fork carries Helix. The decoder is now developed at https://github.com/zackees/minimp3-fixed, and that repository includes
helix/as the benchmark reference it was measured against. It is RPSL/RCSL, not CC0 like the rest of that repo;RPSL.txtandRCSL.txttravel with the code andhelix/README.mdstates plainly that the directory is not part of the library and must not be copied into a product. This was a deliberate call — a number quoted against a decoder nobody can run is not a measurement — but it is a decision worth revisiting now that parity is reached and the reference has served its purpose.Deleting branches does not remove Helix from FastLED's git history. Every commit before #4056 still contains the tree. Removing it from history would require a rewrite, which has not been done and is not proposed here. The claim that holds is precise: Helix is gone from what FastLED ships and from every branch tip that anyone is likely to build.
About 15 recent branches still carry Helix at their tips, simply because they were cut from master before the removal landed and have not been rebased. They will drop it on their next rebase or merge. The three MP3-specific branches (
feat/helix-benchmark-reference,perf/minimp3-fixed-point,feat/mp3-autoresearch) have been deleted; the rest belong to unrelated work.Closing. Reopen if the fork's
helix/directory should be removed as well.