static int joint_decode(COOKContext *q, COOKSubpacket *p, float *mlt_buffer1,

                         float *mlt_buffer2)

{

    int i, j, ret;

    int decouple_tab[SUBBAND_SIZE];

    float *decode_buffer = q->decode_buffer_0;

    int idx, cpl_tmp;

    float f1, f2;

    const float *cplscale;



    memset(decouple_tab, 0, sizeof(decouple_tab));

    memset(decode_buffer, 0, sizeof(q->decode_buffer_0));



    /* Make sure the buffers are zeroed out. */

    memset(mlt_buffer1, 0, 1024 * sizeof(*mlt_buffer1));

    memset(mlt_buffer2, 0, 1024 * sizeof(*mlt_buffer2));

    decouple_info(q, p, decouple_tab);

    if ((ret = mono_decode(q, p, decode_buffer)) < 0)

        return ret;

    /* The two channels are stored interleaved in decode_buffer. */

    for (i = 0; i < p->js_subband_start; i++) {

        for (j = 0; j < SUBBAND_SIZE; j++) {

            mlt_buffer1[i * 20 + j] = decode_buffer[i * 40 + j];

            mlt_buffer2[i * 20 + j] = decode_buffer[i * 40 + 20 + j];

        }

    }



    /* When we reach js_subband_start (the higher frequencies)

       the coefficients are stored in a coupling scheme. */

    idx = (1 << p->js_vlc_bits) - 1;

    for (i = p->js_subband_start; i < p->subbands; i++) {

        cpl_tmp = cplband[i];

        idx -= decouple_tab[cpl_tmp];

        cplscale = q->cplscales[p->js_vlc_bits - 2];  // choose decoupler table

        f1 = cplscale[decouple_tab[cpl_tmp]];

        f2 = cplscale[idx - 1];

        q->decouple(q, p, i, f1, f2, decode_buffer, mlt_buffer1, mlt_buffer2);

        idx = (1 << p->js_vlc_bits) - 1;

    }

    return 0;

}

static int joint_decode(COOKContext *q, COOKSubpacket *p, float *mlt_buffer1,

                         float *mlt_buffer2)

{

    int i, j, ret;

    int decouple_tab[SUBBAND_SIZE];

    float *decode_buffer = q->decode_buffer_0;

    int idx, cpl_tmp;

    float f1, f2;

    const float *cplscale;



    memset(decouple_tab, 0, sizeof(decouple_tab));

    memset(decode_buffer, 0, sizeof(q->decode_buffer_0));



    

    memset(mlt_buffer1, 0, 1024 * sizeof(*mlt_buffer1));

    memset(mlt_buffer2, 0, 1024 * sizeof(*mlt_buffer2));

    decouple_info(q, p, decouple_tab);

    if ((ret = mono_decode(q, p, decode_buffer)) < 0)

        return ret;

    

    for (i = 0; i < p->js_subband_start; i++) {

        for (j = 0; j < SUBBAND_SIZE; j++) {

            mlt_buffer1[i * 20 + j] = decode_buffer[i * 40 + j];

            mlt_buffer2[i * 20 + j] = decode_buffer[i * 40 + 20 + j];

        }

    }



    



    idx = (1 << p->js_vlc_bits) - 1;

    for (i = p->js_subband_start; i < p->subbands; i++) {

        cpl_tmp = cplband[i];

        idx -= decouple_tab[cpl_tmp];

        cplscale = q->cplscales[p->js_vlc_bits - 2];  

        f1 = cplscale[decouple_tab[cpl_tmp]];

        f2 = cplscale[idx - 1];

        q->decouple(q, p, i, f1, f2, decode_buffer, mlt_buffer1, mlt_buffer2);

        idx = (1 << p->js_vlc_bits) - 1;

    }

    return 0;

}

static int FUNC_0(COOKContext *VAR_0, COOKSubpacket *VAR_1, float *VAR_2,

                         float *VAR_3)

{

    int VAR_4, VAR_5, VAR_6;

    int VAR_7[SUBBAND_SIZE];

    float *VAR_8 = VAR_0->decode_buffer_0;

    int VAR_9, VAR_10;

    float VAR_11, VAR_12;

    const float *VAR_13;



    memset(VAR_7, 0, sizeof(VAR_7));

    memset(VAR_8, 0, sizeof(VAR_0->decode_buffer_0));



    

    memset(VAR_2, 0, 1024 * sizeof(*VAR_2));

    memset(VAR_3, 0, 1024 * sizeof(*VAR_3));

    decouple_info(VAR_0, VAR_1, VAR_7);

    if ((VAR_6 = mono_decode(VAR_0, VAR_1, VAR_8)) < 0)

        return VAR_6;

    

    for (VAR_4 = 0; VAR_4 < VAR_1->js_subband_start; VAR_4++) {

        for (VAR_5 = 0; VAR_5 < SUBBAND_SIZE; VAR_5++) {

            VAR_2[VAR_4 * 20 + VAR_5] = VAR_8[VAR_4 * 40 + VAR_5];

            VAR_3[VAR_4 * 20 + VAR_5] = VAR_8[VAR_4 * 40 + 20 + VAR_5];

        }

    }



    



    VAR_9 = (1 << VAR_1->js_vlc_bits) - 1;

    for (VAR_4 = VAR_1->js_subband_start; VAR_4 < VAR_1->subbands; VAR_4++) {

        VAR_10 = cplband[VAR_4];

        VAR_9 -= VAR_7[VAR_10];

        VAR_13 = VAR_0->cplscales[VAR_1->js_vlc_bits - 2];  

        VAR_11 = VAR_13[VAR_7[VAR_10]];

        VAR_12 = VAR_13[VAR_9 - 1];

        VAR_0->decouple(VAR_0, VAR_1, VAR_4, VAR_11, VAR_12, VAR_8, VAR_2, VAR_3);

        VAR_9 = (1 << VAR_1->js_vlc_bits) - 1;

    }

    return 0;

}

static int FUNC_0(COOKContext *VAR_0, COOKSubpacket *VAR_1, float *VAR_2,
float *VAR_3)
{ int VAR_4, VAR_5, VAR_6; int VAR_7[SUBBAND_SIZE]; float *VAR_8 = VAR_0->decode_buffer_0; int VAR_9, VAR_10; float VAR_11, VAR_12; const float *VAR_13; memset(VAR_7, 0, sizeof(VAR_7)); memset(VAR_8, 0, sizeof(VAR_0->decode_buffer_0)); memset(VAR_2, 0, 1024 * sizeof(*VAR_2)); memset(VAR_3, 0, 1024 * sizeof(*VAR_3)); decouple_info(VAR_0, VAR_1, VAR_7); if ((VAR_6 = mono_decode(VAR_0, VAR_1, VAR_8)) < 0)
return VAR_6; for (VAR_4 = 0; VAR_4 < VAR_1->js_subband_start; VAR_4++) { for (VAR_5 = 0; VAR_5 < SUBBAND_SIZE; VAR_5++) { VAR_2[VAR_4 * 20 + VAR_5] = VAR_8[VAR_4 * 40 + VAR_5]; VAR_3[VAR_4 * 20 + VAR_5] = VAR_8[VAR_4 * 40 + 20 + VAR_5]; } } VAR_9 = (1 << VAR_1->js_vlc_bits) - 1; for (VAR_4 = VAR_1->js_subband_start; VAR_4 < VAR_1->subbands; VAR_4++) { VAR_10 = cplband[VAR_4]; VAR_9 -= VAR_7[VAR_10]; VAR_13 = VAR_0->cplscales[VAR_1->js_vlc_bits - 2]; VAR_11 = VAR_13[VAR_7[VAR_10]]; VAR_12 = VAR_13[VAR_9 - 1]; VAR_0->decouple(VAR_0, VAR_1, VAR_4, VAR_11, VAR_12, VAR_8, VAR_2, VAR_3); VAR_9 = (1 << VAR_1->js_vlc_bits) - 1; } return 0; }