Skip to content

Add SILK LPC-to-NLSF conversion (a2nlsf)#157

Merged
thomas-vilte merged 1 commit into
pion:mainfrom
thomas-vilte:feat/silk-a2nlsf
Jul 21, 2026
Merged

Add SILK LPC-to-NLSF conversion (a2nlsf)#157
thomas-vilte merged 1 commit into
pion:mainfrom
thomas-vilte:feat/silk-a2nlsf

Conversation

@thomas-vilte

Copy link
Copy Markdown
Member

Description

adds silk_A2NLSF — converts monic LPC/whitening filter coefficients (Q16) to Normalized Line Spectral Frequencies (Q15). This is root-finding: the filter's even/odd polynomials get evaluated on a fixed cosine grid, with binary-division refinement around each sign crossing, alternating between the two polynomials for each successive root. also includes the float wrapper (a2nlsfFLP) and the bwexpander32 bandwidth-expansion helper used when the root search doesn't converge on the first pass

ported from A2NLSF.c, bwexpander_32.c, and the FLP wrapper in wrappers_FLP.c

one thing worth calling out: the "ran out of retries, fall back to an evenly-spaced white spectrum" branch (maxIterA2NLSF exhausted) is real defensive code in libopus, but I couldn't construct an input that reaches it — threw millions of random and clustered/near-duplicate NLSF vectors at it and the worst case I found needed 16 of the 17 allowed retries. left it uncovered rather than force a contrived case; the rest of the file is in the high 90s/100%

Reference issue

part of the SILK encoder series (#156)

@codecov

codecov Bot commented Jul 20, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 87.38739% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.47%. Comparing base (4221339) to head (30eb2f8).

Files with missing lines Patch % Lines
internal/silk/a2nlsf.go 87.38% 9 Missing and 5 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #157      +/-   ##
==========================================
- Coverage   88.49%   88.47%   -0.02%     
==========================================
  Files          36       37       +1     
  Lines        8074     8185     +111     
==========================================
+ Hits         7145     7242      +97     
- Misses        703      712       +9     
- Partials      226      231       +5     
Flag Coverage Δ
go 88.47% <87.38%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@thomas-vilte
thomas-vilte requested a review from FrantaBOT July 20, 2026 21:40
Co-authored-by: François Allais <francois.allais@hotmail.com>
@thomas-vilte
thomas-vilte merged commit ad89c91 into pion:main Jul 21, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants