apedec: fix signed integer overflows

This bit manipulation is equivalent but avoids undefined
shifts and overflows.

Signed-off-by: Mans Rullgard <mans@mansr.com>
pull/2/head
Mans Rullgard 13 years ago
parent 93c286e54f
commit 644bff6c9b
  1. 2
      libavcodec/apedec.c

@ -690,7 +690,7 @@ static void do_apply_filter(APEContext *ctx, int version, APEFilter *f,
/* Update the adaption coefficients */
absres = FFABS(res);
if (absres)
*f->adaptcoeffs = ((res & (1<<31)) - (1<<30)) >>
*f->adaptcoeffs = ((res & (-1<<31)) ^ (-1<<30)) >>
(25 + (absres <= f->avg*3) + (absres <= f->avg*4/3));
else
*f->adaptcoeffs = 0;

Loading…
Cancel
Save