]> git.sesse.net Git - ffmpeg/commitdiff
avcodec/apedec: properly calculate and store absolute value
authorPaul B Mahol <onemda@gmail.com>
Mon, 5 Oct 2020 23:24:42 +0000 (01:24 +0200)
committerPaul B Mahol <onemda@gmail.com>
Mon, 12 Oct 2020 10:20:26 +0000 (12:20 +0200)
libavcodec/apedec.c

index 273abe2490e22cf71a92777fb2673473c393f9a6..aa4d8fa5242d22be397efb25ddac32f5ee28af86 100644 (file)
@@ -1311,7 +1311,7 @@ static void do_apply_filter(APEContext *ctx, int version, APEFilter *f,
                             int32_t *data, int count, int order, int fracbits)
 {
     int res;
-    int absres;
+    unsigned absres;
 
     while (count--) {
         /* round fixedpoint scalar product */
@@ -1335,7 +1335,7 @@ static void do_apply_filter(APEContext *ctx, int version, APEFilter *f,
             /* Version 3.98 and later files */
 
             /* Update the adaption coefficients */
-            absres = res < 0 ? -(unsigned)res : res;
+            absres = FFABS(res);
             if (absres)
                 *f->adaptcoeffs = APESIGN(res) *
                                   (8 << ((absres > f->avg * 3) + (absres > f->avg * 4 / 3)));