Skip to main content
. 2021 Jul 5;21(13):4602. doi: 10.3390/s21134602
Algorithm 1 Encoder of ADPCM [19].
Require:P // a unit of data to be compressed.
Ensure: p // an ADPCM value.
  w← W_INIT
  Pprev← P_INIT
  C[]←[c0,c1,...,c2M−1]
  fprev←w
  d←P−Pprev
  step←(w×2)/2M−1
  if d>0 then
  if |d|/step>2M−1−1 then
    p←2M−1−1
  else
    p←ceil(d/step)
  end if
  else
  if |d|/step>2M−1 then
    p←2M−1
  else
    p←ceil(−d/step)+2M−1
  end if
 end if
  fprev←fprev×C[p&((1≪M)−1)]/64
  w←fprev