mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-06-28 20:14:02 +08:00
apedec: fix signed integer overflows
This bit manipulation is equivalent but avoids undefined shifts and overflows. Signed-off-by: Mans Rullgard <mans@mansr.com>
This commit is contained in:
@ -690,7 +690,7 @@ static void do_apply_filter(APEContext *ctx, int version, APEFilter *f,
|
|||||||
/* Update the adaption coefficients */
|
/* Update the adaption coefficients */
|
||||||
absres = FFABS(res);
|
absres = FFABS(res);
|
||||||
if (absres)
|
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));
|
(25 + (absres <= f->avg*3) + (absres <= f->avg*4/3));
|
||||||
else
|
else
|
||||||
*f->adaptcoeffs = 0;
|
*f->adaptcoeffs = 0;
|
||||||
|
Reference in New Issue
Block a user