Skip to content

Add SILK fixed-point math primitives#153

Merged
thomas-vilte merged 2 commits into
pion:mainfrom
thomas-vilte:feat/silk-math-primitives
Jul 18, 2026
Merged

Add SILK fixed-point math primitives#153
thomas-vilte merged 2 commits into
pion:mainfrom
thomas-vilte:feat/silk-math-primitives

Conversation

@thomas-vilte

Copy link
Copy Markdown
Member

Add math_fix.go with fixed-point arithmetic primitives copied from libopus Inlines.h and MacroCount.h:

  • smulbb, smlabb, smulww, smulwt, smlawt (Q-format multiply/accumulate)
  • sub32Ovflw, add32Ovflw (wrapping arithmetic)
  • addLShift32, addSat32, lshiftSat32, lshiftOvflw (saturating shifts)
  • clampI64, silkRand (utility)
  • smlabbOvflw, div32VarQ, sat16, addPosSat32 (advanced arithmetic)
  • sqrtApprox (silk_SQRT_APPROX)
  • sigmQ15 (silk_sigm_Q15 with LUT tables)

Add lin2log.go with log helpers:

  • ror32, clzFrac (bit manipulation)
  • smlawb, lin2log (logarithm approximation)
  • silkLog2 (base-2 logarithm)

Add math_fix_test.go with tests for div32VarQ, smulwt, addSat32, silkRand.

All functions are tested but currently unused by production code.
They will be consumed by subsequent SILK sub-PRs (VAD, NSQ,
pitch analysis, noise shaping, etc.).

@codecov

codecov Bot commented Jul 17, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 99.05660% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 88.19%. Comparing base (44da8bb) to head (e1a9a36).

Files with missing lines Patch % Lines
internal/silk/math_fix.go 98.80% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #153      +/-   ##
==========================================
+ Coverage   88.04%   88.19%   +0.14%     
==========================================
  Files          32       34       +2     
  Lines        7762     7868     +106     
==========================================
+ Hits         6834     6939     +105     
- Misses        702      703       +1     
  Partials      226      226              
Flag Coverage Δ
go 88.19% <99.05%> (+0.14%) ⬆️

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.

Comment thread pion_opus_contribution.md Outdated
@@ -0,0 +1,2294 @@
# Plan: Contribución del Encoder Opus a pion/opus

@JoTurk JoTurk Jul 17, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this file comitted by mistake?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, my bad — that got committed by accident, unrelated file. already force-pushed it out, should be gone from the diff now

@thomas-vilte
thomas-vilte force-pushed the feat/silk-math-primitives branch from f89119e to 1d010c0 Compare July 17, 2026 22:34
@thomas-vilte thomas-vilte changed the title feat(silk): add fixed-point math and log primitives Add SILK fixed-point math primitives Jul 17, 2026

@JoTurk JoTurk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, we should remove all the nolint:unused when we start using them

@thomas-vilte
thomas-vilte merged commit 4bed3b6 into pion:main Jul 18, 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