xiph / xiph/opus

Is there any references to the algorithm of celt_exp2/celt_log2 function?

Open
#230 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
3.3k
Forks
808
PR merge metrics
No merged PRs in 30d

Description

I can't understand the algorithm of celt_exp2/celt_log2 function.
Is there any references to this algorithm ?
Thank you!

/** Base-2 exponential approximation (2^x). */
static OPUS_INLINE float celt_exp2(float x)
{
   int integer;
   float frac;
   union {
      float f;
      opus_uint32 i;
   } res;
   integer = floor(x);
   if (integer < -50)
      return 0;
   frac = x-integer;
   /* K0 = 1, K1 = log(2), K2 = 3-4*log(2), K3 = 3*log(2) - 2 */
   res.f = 0.99992522f + frac * (0.69583354f
           + frac * (0.22606716f + 0.078024523f*frac));
   res.i = (res.i + ((opus_uint32)integer<<23)) & 0x7fffffff;
   return res.f;
}

K0 = 1
K1 = log(2) = 0.69314718056
K2 = 3 - 4log(2) = 0.22741127776
K3 = 3
log(2) - 2 = 0.07944154167

why its different from the next line?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the celt_exp2 and celt_log2 entry points in the Opus source and trace the surrounding comments and constants. Look for referenced algorithm notes or documentation explaining the approximation; done means documenting the coefficient source and why the listed K values differ from the implementation.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
audio-video-rtc
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.