Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use a shift instead of div to have bit exact output for MS Adpcm codec. #306

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions symphonia-codec-adpcm/src/codec_ms.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,12 @@ impl AdpcmMsBlockStatus {
fn expand_nibble(&mut self, byte: u8, nibble: Nibble) -> i32 {
let nibble = nibble.get_nibble(byte);
let signed_nibble = signed_nibble(nibble) as i32;
let predictor = ((self.sample1 * self.coeff1) + (self.sample2 * self.coeff2)) / 256
let predictor = ((self.sample1 * self.coeff1) + (self.sample2 * self.coeff2))
.wrapping_shr(8)
+ signed_nibble * self.delta;
self.sample2 = self.sample1;
self.sample1 = clamp_i16(predictor) as i32;
self.delta = (MS_ADAPTATION_TABLE[nibble as usize] * self.delta) / 256;
self.delta = (MS_ADAPTATION_TABLE[nibble as usize] * self.delta).wrapping_shr(8);
self.delta = self.delta.max(DELTA_MIN);
from_i16_shift!(self.sample1)
}
Expand Down