static int decorrelate(TAKDecContext *s, int c1, int c2, int length)

{

    GetBitContext *gb = &s->gb;

    int32_t *p1       = s->decoded[c1] + 1;

    int32_t *p2       = s->decoded[c2] + 1;

    int i;

    int dshift, dfactor;



    switch (s->dmode) {

    case 1: /* left/side */

        for (i = 0; i < length; i++) {

            int32_t a = p1[i];

            int32_t b = p2[i];

            p2[i]     = a + b;

        }

        break;

    case 2: /* side/right */

        for (i = 0; i < length; i++) {

            int32_t a = p1[i];

            int32_t b = p2[i];

            p1[i]     = b - a;

        }

        break;

    case 3: /* side/mid */

        for (i = 0; i < length; i++) {

            int32_t a = p1[i];

            int32_t b = p2[i];

            a        -= b >> 1;

            p1[i]     = a;

            p2[i]     = a + b;

        }

        break;

    case 4: /* side/left with scale factor */

        FFSWAP(int32_t*, p1, p2);

    case 5: /* side/right with scale factor */

        dshift  = get_bits_esc4(gb);

        dfactor = get_sbits(gb, 10);

        for (i = 0; i < length; i++) {

            int32_t a = p1[i];

            int32_t b = p2[i];

            b         = dfactor * (b >> dshift) + 128 >> 8 << dshift;

            p1[i]     = b - a;

        }

        break;

    case 6:

        FFSWAP(int32_t*, p1, p2);

    case 7: {

        int length2, order_half, filter_order, dval1, dval2;

        int tmp, x, code_size;



        if (length < 256)

            return AVERROR_INVALIDDATA;



        dshift       = get_bits_esc4(gb);

        filter_order = 8 << get_bits1(gb);

        dval1        = get_bits1(gb);

        dval2        = get_bits1(gb);



        AV_ZERO128(s->filter + 8);

        for (i = 0; i < filter_order; i++) {

            if (!(i & 3))

                code_size = 14 - get_bits(gb, 3);

            s->filter[i] = get_sbits(gb, code_size);

        }



        order_half = filter_order / 2;

        length2    = length - (filter_order - 1);



        /* decorrelate beginning samples */

        if (dval1) {

            for (i = 0; i < order_half; i++) {

                int32_t a = p1[i];

                int32_t b = p2[i];

                p1[i]     = a + b;

            }

        }



        /* decorrelate ending samples */

        if (dval2) {

            for (i = length2 + order_half; i < length; i++) {

                int32_t a = p1[i];

                int32_t b = p2[i];

                p1[i]     = a + b;

            }

        }





        for (i = 0; i < filter_order; i++)

            s->residues[i] = *p2++ >> dshift;



        p1 += order_half;

        x = FF_ARRAY_ELEMS(s->residues) - filter_order;

        for (; length2 > 0; length2 -= tmp) {

            tmp = FFMIN(length2, x);



            for (i = 0; i < tmp; i++)

                s->residues[filter_order + i] = *p2++ >> dshift;



            for (i = 0; i < tmp; i++) {

                int v = 1 << 9;



                v += s->adsp.scalarproduct_int16(&s->residues[i], s->filter, 16);

                v = (av_clip_intp2(v >> 10, 13) << dshift) - *p1;

                *p1++ = v;

            }



            memcpy(s->residues, &s->residues[tmp], 2 * filter_order);

        }



        emms_c();

        break;

    }

    }



    return 0;

}

static int decorrelate(TAKDecContext *s, int c1, int c2, int length)

{

    GetBitContext *gb = &s->gb;

    int32_t *p1       = s->decoded[c1] + 1;

    int32_t *p2       = s->decoded[c2] + 1;

    int i;

    int dshift, dfactor;



    switch (s->dmode) {

    case 1: 

        for (i = 0; i < length; i++) {

            int32_t a = p1[i];

            int32_t b = p2[i];

            p2[i]     = a + b;

        }

        break;

    case 2: 

        for (i = 0; i < length; i++) {

            int32_t a = p1[i];

            int32_t b = p2[i];

            p1[i]     = b - a;

        }

        break;

    case 3: 

        for (i = 0; i < length; i++) {

            int32_t a = p1[i];

            int32_t b = p2[i];

            a        -= b >> 1;

            p1[i]     = a;

            p2[i]     = a + b;

        }

        break;

    case 4: 

        FFSWAP(int32_t*, p1, p2);

    case 5: 

        dshift  = get_bits_esc4(gb);

        dfactor = get_sbits(gb, 10);

        for (i = 0; i < length; i++) {

            int32_t a = p1[i];

            int32_t b = p2[i];

            b         = dfactor * (b >> dshift) + 128 >> 8 << dshift;

            p1[i]     = b - a;

        }

        break;

    case 6:

        FFSWAP(int32_t*, p1, p2);

    case 7: {

        int length2, order_half, filter_order, dval1, dval2;

        int tmp, x, code_size;



        if (length < 256)

            return AVERROR_INVALIDDATA;



        dshift       = get_bits_esc4(gb);

        filter_order = 8 << get_bits1(gb);

        dval1        = get_bits1(gb);

        dval2        = get_bits1(gb);



        AV_ZERO128(s->filter + 8);

        for (i = 0; i < filter_order; i++) {

            if (!(i & 3))

                code_size = 14 - get_bits(gb, 3);

            s->filter[i] = get_sbits(gb, code_size);

        }



        order_half = filter_order / 2;

        length2    = length - (filter_order - 1);



        

        if (dval1) {

            for (i = 0; i < order_half; i++) {

                int32_t a = p1[i];

                int32_t b = p2[i];

                p1[i]     = a + b;

            }

        }



        

        if (dval2) {

            for (i = length2 + order_half; i < length; i++) {

                int32_t a = p1[i];

                int32_t b = p2[i];

                p1[i]     = a + b;

            }

        }





        for (i = 0; i < filter_order; i++)

            s->residues[i] = *p2++ >> dshift;



        p1 += order_half;

        x = FF_ARRAY_ELEMS(s->residues) - filter_order;

        for (; length2 > 0; length2 -= tmp) {

            tmp = FFMIN(length2, x);



            for (i = 0; i < tmp; i++)

                s->residues[filter_order + i] = *p2++ >> dshift;



            for (i = 0; i < tmp; i++) {

                int v = 1 << 9;



                v += s->adsp.scalarproduct_int16(&s->residues[i], s->filter, 16);

                v = (av_clip_intp2(v >> 10, 13) << dshift) - *p1;

                *p1++ = v;

            }



            memcpy(s->residues, &s->residues[tmp], 2 * filter_order);

        }



        emms_c();

        break;

    }

    }



    return 0;

}

        AV_ZERO128(s->filter + 8);                 v += s->adsp.scalarproduct_int16(&s->residues[i], s->filter, 16);
static int FUNC_0(TAKDecContext *VAR_0, int VAR_1, int VAR_2, int VAR_3)

{

    GetBitContext *gb = &VAR_0->gb;

    int32_t *p1       = VAR_0->decoded[VAR_1] + 1;

    int32_t *p2       = VAR_0->decoded[VAR_2] + 1;

    int VAR_4;

    int VAR_5, VAR_6;



    switch (VAR_0->dmode) {

    case 1: 

        for (VAR_4 = 0; VAR_4 < VAR_3; VAR_4++) {

            int32_t a = p1[VAR_4];

            int32_t b = p2[VAR_4];

            p2[VAR_4]     = a + b;

        }

        break;

    case 2: 

        for (VAR_4 = 0; VAR_4 < VAR_3; VAR_4++) {

            int32_t a = p1[VAR_4];

            int32_t b = p2[VAR_4];

            p1[VAR_4]     = b - a;

        }

        break;

    case 3: 

        for (VAR_4 = 0; VAR_4 < VAR_3; VAR_4++) {

            int32_t a = p1[VAR_4];

            int32_t b = p2[VAR_4];

            a        -= b >> 1;

            p1[VAR_4]     = a;

            p2[VAR_4]     = a + b;

        }

        break;

    case 4: 

        FFSWAP(int32_t*, p1, p2);

    case 5: 

        VAR_5  = get_bits_esc4(gb);

        VAR_6 = get_sbits(gb, 10);

        for (VAR_4 = 0; VAR_4 < VAR_3; VAR_4++) {

            int32_t a = p1[VAR_4];

            int32_t b = p2[VAR_4];

            b         = VAR_6 * (b >> VAR_5) + 128 >> 8 << VAR_5;

            p1[VAR_4]     = b - a;

        }

        break;

    case 6:

        FFSWAP(int32_t*, p1, p2);

    case 7: {

        int VAR_7, VAR_8, VAR_9, VAR_10, VAR_11;

        int VAR_12, VAR_13, VAR_14;



        if (VAR_3 < 256)

            return AVERROR_INVALIDDATA;



        VAR_5       = get_bits_esc4(gb);

        VAR_9 = 8 << get_bits1(gb);

        VAR_10        = get_bits1(gb);

        VAR_11        = get_bits1(gb);



        AV_ZERO128(VAR_0->filter + 8);

        for (VAR_4 = 0; VAR_4 < VAR_9; VAR_4++) {

            if (!(VAR_4 & 3))

                VAR_14 = 14 - get_bits(gb, 3);

            VAR_0->filter[VAR_4] = get_sbits(gb, VAR_14);

        }



        VAR_8 = VAR_9 / 2;

        VAR_7    = VAR_3 - (VAR_9 - 1);



        

        if (VAR_10) {

            for (VAR_4 = 0; VAR_4 < VAR_8; VAR_4++) {

                int32_t a = p1[VAR_4];

                int32_t b = p2[VAR_4];

                p1[VAR_4]     = a + b;

            }

        }



        

        if (VAR_11) {

            for (VAR_4 = VAR_7 + VAR_8; VAR_4 < VAR_3; VAR_4++) {

                int32_t a = p1[VAR_4];

                int32_t b = p2[VAR_4];

                p1[VAR_4]     = a + b;

            }

        }





        for (VAR_4 = 0; VAR_4 < VAR_9; VAR_4++)

            VAR_0->residues[VAR_4] = *p2++ >> VAR_5;



        p1 += VAR_8;

        VAR_13 = FF_ARRAY_ELEMS(VAR_0->residues) - VAR_9;

        for (; VAR_7 > 0; VAR_7 -= VAR_12) {

            VAR_12 = FFMIN(VAR_7, VAR_13);



            for (VAR_4 = 0; VAR_4 < VAR_12; VAR_4++)

                VAR_0->residues[VAR_9 + VAR_4] = *p2++ >> VAR_5;



            for (VAR_4 = 0; VAR_4 < VAR_12; VAR_4++) {

                int VAR_15 = 1 << 9;



                VAR_15 += VAR_0->adsp.scalarproduct_int16(&VAR_0->residues[VAR_4], VAR_0->filter, 16);

                VAR_15 = (av_clip_intp2(VAR_15 >> 10, 13) << VAR_5) - *p1;

                *p1++ = VAR_15;

            }



            memcpy(VAR_0->residues, &VAR_0->residues[VAR_12], 2 * VAR_9);

        }



        emms_c();

        break;

    }

    }



    return 0;

}

static int FUNC_0(TAKDecContext *VAR_0, int VAR_1, int VAR_2, int VAR_3)
{ GetBitContext *gb = &VAR_0->gb; int32_t *p1       = VAR_0->decoded[VAR_1] + 1; int32_t *p2       = VAR_0->decoded[VAR_2] + 1; int VAR_4; int VAR_5, VAR_6; switch (VAR_0->dmode) { case 1:
for (VAR_4 = 0; VAR_4 < VAR_3; VAR_4++) { int32_t a = p1[VAR_4]; int32_t b = p2[VAR_4]; p2[VAR_4]     = a + b; } break; case 2:
for (VAR_4 = 0; VAR_4 < VAR_3; VAR_4++) { int32_t a = p1[VAR_4]; int32_t b = p2[VAR_4]; p1[VAR_4]     = b - a; } break; case 3:
for (VAR_4 = 0; VAR_4 < VAR_3; VAR_4++) { int32_t a = p1[VAR_4]; int32_t b = p2[VAR_4]; a        -= b >> 1; p1[VAR_4]     = a; p2[VAR_4]     = a + b; } break; case 4:
FFSWAP(int32_t*, p1, p2); case 5:
VAR_5  = get_bits_esc4(gb); VAR_6 = get_sbits(gb, 10); for (VAR_4 = 0; VAR_4 < VAR_3; VAR_4++) { int32_t a = p1[VAR_4]; int32_t b = p2[VAR_4]; b         = VAR_6 * (b >> VAR_5) + 128 >> 8 << VAR_5; p1[VAR_4]     = b - a; } break; case 6:
FFSWAP(int32_t*, p1, p2); case 7: { int VAR_7, VAR_8, VAR_9, VAR_10, VAR_11; int VAR_12, VAR_13, VAR_14; if (VAR_3 < 256)
return AVERROR_INVALIDDATA; VAR_5       = get_bits_esc4(gb); VAR_9 = 8 << get_bits1(gb); VAR_10        = get_bits1(gb); VAR_11        = get_bits1(gb); AV_ZERO128(VAR_0->filter + 8); for (VAR_4 = 0; VAR_4 < VAR_9; VAR_4++) { if (!(VAR_4 & 3))
VAR_14 = 14 - get_bits(gb, 3); VAR_0->filter[VAR_4] = get_sbits(gb, VAR_14); } VAR_8 = VAR_9 / 2; VAR_7    = VAR_3 - (VAR_9 - 1); if (VAR_10) { for (VAR_4 = 0; VAR_4 < VAR_8; VAR_4++) { int32_t a = p1[VAR_4]; int32_t b = p2[VAR_4]; p1[VAR_4]     = a + b; } } if (VAR_11) { for (VAR_4 = VAR_7 + VAR_8; VAR_4 < VAR_3; VAR_4++) { int32_t a = p1[VAR_4]; int32_t b = p2[VAR_4]; p1[VAR_4]     = a + b; } } for (VAR_4 = 0; VAR_4 < VAR_9; VAR_4++) VAR_0->residues[VAR_4] = *p2++ >> VAR_5; p1 += VAR_8; VAR_13 = FF_ARRAY_ELEMS(VAR_0->residues) - VAR_9; for (; VAR_7 > 0; VAR_7 -= VAR_12) { VAR_12 = FFMIN(VAR_7, VAR_13); for (VAR_4 = 0; VAR_4 < VAR_12; VAR_4++) VAR_0->residues[VAR_9 + VAR_4] = *p2++ >> VAR_5; for (VAR_4 = 0; VAR_4 < VAR_12; VAR_4++) { int VAR_15 = 1 << 9; VAR_15 += VAR_0->adsp.scalarproduct_int16(&VAR_0->residues[VAR_4], VAR_0->filter, 16); VAR_15 = (av_clip_intp2(VAR_15 >> 10, 13) << VAR_5) - *p1; *p1++ = VAR_15; } memcpy(VAR_0->residues, &VAR_0->residues[VAR_12], 2 * VAR_9); } emms_c(); break; } } return 0; }