static void do_apply_filter(APEContext *ctx, int version, APEFilter *f,

                            int32_t *data, int count, int order, int fracbits)

{

    int res;

    int absres;



    while (count--) {

        /* round fixedpoint scalar product */

        res = ctx->adsp.scalarproduct_and_madd_int16(f->coeffs,

                                                     f->delay - order,

                                                     f->adaptcoeffs - order,

                                                     order, APESIGN(*data));

        res = (res + (1 << (fracbits - 1))) >> fracbits;

        res += *data;

        *data++ = res;



        /* Update the output history */

        *f->delay++ = av_clip_int16(res);



        if (version < 3980) {

            /* Version ??? to < 3.98 files (untested) */

            f->adaptcoeffs[0]  = (res == 0) ? 0 : ((res >> 28) & 8) - 4;

            f->adaptcoeffs[-4] >>= 1;

            f->adaptcoeffs[-8] >>= 1;

        } else {

            /* Version 3.98 and later files */



            /* Update the adaption coefficients */

            absres = FFABS(res);

            if (absres)

                *f->adaptcoeffs = ((res & (-1<<31)) ^ (-1<<30)) >>

                                  (25 + (absres <= f->avg*3) + (absres <= f->avg*4/3));

            else

                *f->adaptcoeffs = 0;



            f->avg += (absres - f->avg) / 16;



            f->adaptcoeffs[-1] >>= 1;

            f->adaptcoeffs[-2] >>= 1;

            f->adaptcoeffs[-8] >>= 1;

        }



        f->adaptcoeffs++;



        /* Have we filled the history buffer? */

        if (f->delay == f->historybuffer + HISTORY_SIZE + (order * 2)) {

            memmove(f->historybuffer, f->delay - (order * 2),

                    (order * 2) * sizeof(*f->historybuffer));

            f->delay = f->historybuffer + order * 2;

            f->adaptcoeffs = f->historybuffer + order;

        }

    }

}

static void do_apply_filter(APEContext *ctx, int version, APEFilter *f,

                            int32_t *data, int count, int order, int fracbits)

{

    int res;

    int absres;



    while (count--) {

        

        res = ctx->adsp.scalarproduct_and_madd_int16(f->coeffs,

                                                     f->delay - order,

                                                     f->adaptcoeffs - order,

                                                     order, APESIGN(*data));

        res = (res + (1 << (fracbits - 1))) >> fracbits;

        res += *data;

        *data++ = res;



        

        *f->delay++ = av_clip_int16(res);



        if (version < 3980) {

            

            f->adaptcoeffs[0]  = (res == 0) ? 0 : ((res >> 28) & 8) - 4;

            f->adaptcoeffs[-4] >>= 1;

            f->adaptcoeffs[-8] >>= 1;

        } else {

            



            

            absres = FFABS(res);

            if (absres)

                *f->adaptcoeffs = ((res & (-1<<31)) ^ (-1<<30)) >>

                                  (25 + (absres <= f->avg*3) + (absres <= f->avg*4/3));

            else

                *f->adaptcoeffs = 0;



            f->avg += (absres - f->avg) / 16;



            f->adaptcoeffs[-1] >>= 1;

            f->adaptcoeffs[-2] >>= 1;

            f->adaptcoeffs[-8] >>= 1;

        }



        f->adaptcoeffs++;



        

        if (f->delay == f->historybuffer + HISTORY_SIZE + (order * 2)) {

            memmove(f->historybuffer, f->delay - (order * 2),

                    (order * 2) * sizeof(*f->historybuffer));

            f->delay = f->historybuffer + order * 2;

            f->adaptcoeffs = f->historybuffer + order;

        }

    }

}

                *f->adaptcoeffs = ((res & (-1<<31)) ^ (-1<<30)) >>
static void FUNC_0(APEContext *VAR_0, int VAR_1, APEFilter *VAR_2,

                            int32_t *VAR_3, int VAR_4, int VAR_5, int VAR_6)

{

    int VAR_7;

    int VAR_8;



    while (VAR_4--) {

        

        VAR_7 = VAR_0->adsp.scalarproduct_and_madd_int16(VAR_2->coeffs,

                                                     VAR_2->delay - VAR_5,

                                                     VAR_2->adaptcoeffs - VAR_5,

                                                     VAR_5, APESIGN(*VAR_3));

        VAR_7 = (VAR_7 + (1 << (VAR_6 - 1))) >> VAR_6;

        VAR_7 += *VAR_3;

        *VAR_3++ = VAR_7;



        

        *VAR_2->delay++ = av_clip_int16(VAR_7);



        if (VAR_1 < 3980) {

            

            VAR_2->adaptcoeffs[0]  = (VAR_7 == 0) ? 0 : ((VAR_7 >> 28) & 8) - 4;

            VAR_2->adaptcoeffs[-4] >>= 1;

            VAR_2->adaptcoeffs[-8] >>= 1;

        } else {

            



            

            VAR_8 = FFABS(VAR_7);

            if (VAR_8)

                *VAR_2->adaptcoeffs = ((VAR_7 & (-1<<31)) ^ (-1<<30)) >>

                                  (25 + (VAR_8 <= VAR_2->avg*3) + (VAR_8 <= VAR_2->avg*4/3));

            else

                *VAR_2->adaptcoeffs = 0;



            VAR_2->avg += (VAR_8 - VAR_2->avg) / 16;



            VAR_2->adaptcoeffs[-1] >>= 1;

            VAR_2->adaptcoeffs[-2] >>= 1;

            VAR_2->adaptcoeffs[-8] >>= 1;

        }



        VAR_2->adaptcoeffs++;



        

        if (VAR_2->delay == VAR_2->historybuffer + HISTORY_SIZE + (VAR_5 * 2)) {

            memmove(VAR_2->historybuffer, VAR_2->delay - (VAR_5 * 2),

                    (VAR_5 * 2) * sizeof(*VAR_2->historybuffer));

            VAR_2->delay = VAR_2->historybuffer + VAR_5 * 2;

            VAR_2->adaptcoeffs = VAR_2->historybuffer + VAR_5;

        }

    }

}

static void FUNC_0(APEContext *VAR_0, int VAR_1, APEFilter *VAR_2,
int32_t *VAR_3, int VAR_4, int VAR_5, int VAR_6)
{ int VAR_7; int VAR_8; while (VAR_4--) { VAR_7 = VAR_0->adsp.scalarproduct_and_madd_int16(VAR_2->coeffs,
VAR_2->delay - VAR_5,
VAR_2->adaptcoeffs - VAR_5,
VAR_5, APESIGN(*VAR_3)); VAR_7 = (VAR_7 + (1 << (VAR_6 - 1))) >> VAR_6; VAR_7 += *VAR_3; *VAR_3++ = VAR_7; *VAR_2->delay++ = av_clip_int16(VAR_7); if (VAR_1 < 3980) { VAR_2->adaptcoeffs[0]  = (VAR_7 == 0) ? 0 : ((VAR_7 >> 28) & 8) - 4; VAR_2->adaptcoeffs[-4] >>= 1; VAR_2->adaptcoeffs[-8] >>= 1; } else { VAR_8 = FFABS(VAR_7); if (VAR_8)
*VAR_2->adaptcoeffs = ((VAR_7 & (-1<<31)) ^ (-1<<30)) >>
(25 + (VAR_8 <= VAR_2->avg*3) + (VAR_8 <= VAR_2->avg*4/3)); else
*VAR_2->adaptcoeffs = 0; VAR_2->avg += (VAR_8 - VAR_2->avg) / 16; VAR_2->adaptcoeffs[-1] >>= 1; VAR_2->adaptcoeffs[-2] >>= 1; VAR_2->adaptcoeffs[-8] >>= 1; } VAR_2->adaptcoeffs++; if (VAR_2->delay == VAR_2->historybuffer + HISTORY_SIZE + (VAR_5 * 2)) { memmove(VAR_2->historybuffer, VAR_2->delay - (VAR_5 * 2),
(VAR_5 * 2) * sizeof(*VAR_2->historybuffer)); VAR_2->delay = VAR_2->historybuffer + VAR_5 * 2; VAR_2->adaptcoeffs = VAR_2->historybuffer + VAR_5; } } }