Skip to main content
. 2021 Jul 5;21(13):4602. doi: 10.3390/s21134602
Algorithm 6 Variable bit-length ADPCM decoder.
Require:p // ADPCM value.
Require: M // bits of the current ADPCM value.
Require: InitW // if the predicted offset is initialized or not.
Require: Winit // a predicted offset to be initialized.
Require: InitP // if the Pprev is initialized or not.
Require: Pinit // an original data to be set to Pprev.
Ensure: P // N bit Pixel element.
 if M=N then
   P←p
  return
 end if
 if M≠Mprev then
  if M>Mprev then
    w←w≪(M−Mprev)
  else
    w←w≫(Mprev−M)
  end if
 end if
 if InitW=true then
   w←Winit
 end if
 if InitP=true then
   Pprev←Pinit
 end if
  step←(w×2)/2M−1
 if p<2M−1 then
   d←step×(p×2+1)/2
 else
   d←−step×((p−2M−1)×2+1)/2
 end if
  P←Pprev+d
  fprev←fprev×C[p&((1≪M)−1)]/64
  w←fprev