X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fapedec.c;h=1e89a7bdb1906ccc086dd7b513b3c6f0ee52c4f8;hb=7aa16d59bfc537db69ffb08b9d5ec5f868cff56a;hp=de9d71ca40524301cebfe61ab75b52013f18d29b;hpb=f4c88eef95e6d4a2463ce2fbae2c5d1a20eb1373;p=ffmpeg diff --git a/libavcodec/apedec.c b/libavcodec/apedec.c index de9d71ca405..1e89a7bdb19 100644 --- a/libavcodec/apedec.c +++ b/libavcodec/apedec.c @@ -1284,8 +1284,16 @@ static void do_apply_filter(APEContext *ctx, int version, APEFilter *f, /* Update the adaption coefficients */ absres = FFABS(res); if (absres) - *f->adaptcoeffs = ((res & INT32_MIN) ^ (-(1<<30))) >> - (25 + (absres <= f->avg*3) + (absres <= f->avg*4/3)); + *f->adaptcoeffs = APESIGN(res) * + (8 << ((absres > f->avg * 3) + (absres > f->avg * 4 / 3))); + /* equivalent to the following code + if (absres <= f->avg * 4 / 3) + *f->adaptcoeffs = APESIGN(res) * 8; + else if (absres <= f->avg * 3) + *f->adaptcoeffs = APESIGN(res) * 16; + else + *f->adaptcoeffs = APESIGN(res) * 32; + */ else *f->adaptcoeffs = 0;