iSAC fix entropy coder: Recently added DCHECK could in fact trigger

A DCHECK added in a recent bugfix, which asserted that a signed 64->32
bit cast did not overflow, has been found to not always pass. We fix
this by saturating.

BUG=chromium:693868

Review-Url: https://codereview.webrtc.org/2746903002
Cr-Commit-Position: refs/heads/master@{#17209}
This commit is contained in:
kwiberg
2017-03-13 05:28:47 -07:00
committed by Commit bot
parent 53dc23c28f
commit a1896a649c
2 changed files with 6 additions and 2 deletions

View File

@ -234,8 +234,7 @@ static void CalcInvArSpec(const int16_t *ARCoefQ12,
for (n = 0; n < FRAMESAMPLES/8; n++) {
const int64_t p =
(WebRtcIsacfix_kCos[k][n] * (int64_t)CorrQ11[k + 1] + 2) >> 2;
RTC_DCHECK_EQ(p, (int32_t)p); // p fits in 32 bits
CurveQ16[n] += (int32_t)p;
CurveQ16[n] += WebRtcSpl_SatW64ToW32(p);
}
}