static int decode_subpacket(COOKContext *q, uint8_t *inbuffer,

                            int sub_packet_size, int16_t *outbuffer) {

    int i,j;

    int value;

    float* tmp_ptr;



    /* packet dump */

//    for (i=0 ; i<sub_packet_size ; i++) {

//        av_log(NULL, AV_LOG_ERROR, "%02x", inbuffer[i]);

//    }

//    av_log(NULL, AV_LOG_ERROR, "\n");



    decode_bytes(inbuffer, q->decoded_bytes_buffer, sub_packet_size);

    init_get_bits(&q->gb, q->decoded_bytes_buffer, sub_packet_size*8);

    decode_gain_info(&q->gb, &q->gain_current);

    memcpy(&q->gain_copy, &q->gain_current ,sizeof(COOKgain));  //This copy does not seem to be used. FIXME



    if(q->nb_channels==2 && q->joint_stereo==1){

        joint_decode(q, q->decode_buf_ptr[0], q->decode_buf_ptr[2]);



        /* Swap buffer pointers. */

        tmp_ptr = q->decode_buf_ptr[1];

        q->decode_buf_ptr[1] = q->decode_buf_ptr[0];

        q->decode_buf_ptr[0] = tmp_ptr;

        tmp_ptr = q->decode_buf_ptr[3];

        q->decode_buf_ptr[3] = q->decode_buf_ptr[2];

        q->decode_buf_ptr[2] = tmp_ptr;



        /* FIXME: Rethink the gainbuffer handling, maybe a rename?

           now/previous swap */

        q->gain_now_ptr = &q->gain_now;

        q->gain_previous_ptr = &q->gain_previous;

        for (i=0 ; i<q->nb_channels ; i++){



            cook_imlt(q, q->decode_buf_ptr[i*2], q->mono_mdct_output, q->mlt_tmp);

            gain_compensate(q, q->mono_mdct_output, q->gain_now_ptr,

                            q->gain_previous_ptr, q->previous_buffer_ptr[0]);



            /* Swap out the previous buffer. */

            tmp_ptr = q->previous_buffer_ptr[0];

            q->previous_buffer_ptr[0] = q->previous_buffer_ptr[1];

            q->previous_buffer_ptr[1] = tmp_ptr;



            /* Clip and convert the floats to 16 bits. */

            for (j=0 ; j<q->samples_per_frame ; j++){

                value = lrintf(q->mono_mdct_output[j]);

                if(value < -32768) value = -32768;

                else if(value > 32767) value = 32767;

                outbuffer[2*j+i] = value;

            }

        }



        memcpy(&q->gain_now, &q->gain_previous, sizeof(COOKgain));

        memcpy(&q->gain_previous, &q->gain_current, sizeof(COOKgain));



    } else if (q->nb_channels==2 && q->joint_stereo==0) {

            /* channel 0 */

            mono_decode(q, q->decode_buf_ptr[0]);



            tmp_ptr = q->decode_buf_ptr[0];

            q->decode_buf_ptr[0] = q->decode_buf_ptr[1];

            q->decode_buf_ptr[1] = q->decode_buf_ptr[2];

            q->decode_buf_ptr[2] = q->decode_buf_ptr[3];

            q->decode_buf_ptr[3] = tmp_ptr;



            q->gain_now_ptr = &q->gain_now;

            q->gain_previous_ptr = &q->gain_previous;



            cook_imlt(q, q->decode_buf_ptr[0], q->mono_mdct_output,q->mlt_tmp);

            gain_compensate(q, q->mono_mdct_output, q->gain_now_ptr,

                            q->gain_previous_ptr, q->previous_buffer_ptr[0]);

            /* Swap out the previous buffer. */

            tmp_ptr = q->previous_buffer_ptr[0];

            q->previous_buffer_ptr[0] = q->previous_buffer_ptr[1];

            q->previous_buffer_ptr[1] = tmp_ptr;



            for (j=0 ; j<q->samples_per_frame ; j++){

                value = lrintf(q->mono_mdct_output[j]);

                if(value < -32768) value = -32768;

                else if(value > 32767) value = 32767;

                outbuffer[2*j+1] = value;

            }



            /* channel 1 */

            //av_log(NULL,AV_LOG_ERROR,"bits = %d\n",get_bits_count(&q->gb));

            init_get_bits(&q->gb, q->decoded_bytes_buffer, sub_packet_size*8+q->bits_per_subpacket);

            decode_gain_info(&q->gb, &q->gain_current);

            //memcpy(&q->gain_copy, &q->gain_current ,sizeof(COOKgain));

            mono_decode(q, q->decode_buf_ptr[0]);

            tmp_ptr = q->decode_buf_ptr[0];

            q->decode_buf_ptr[1] = q->decode_buf_ptr[2];

            q->decode_buf_ptr[2] = q->decode_buf_ptr[3];

            q->decode_buf_ptr[3] = tmp_ptr;



            q->gain_now_ptr = &q->gain_now;

            q->gain_previous_ptr = &q->gain_previous;



            cook_imlt(q, q->decode_buf_ptr[0], q->mono_mdct_output,q->mlt_tmp);

            gain_compensate(q, q->mono_mdct_output, q->gain_now_ptr, q->gain_previous_ptr, q->previous_buffer_ptr[0]);



            /* Swap out the previous buffer. */

            tmp_ptr = q->previous_buffer_ptr[0];

            q->previous_buffer_ptr[0] = q->previous_buffer_ptr[1];

            q->previous_buffer_ptr[1] = tmp_ptr;



            for (j=0 ; j<q->samples_per_frame ; j++){

                value = lrintf(q->mono_mdct_output[j]);

                if(value < -32768) value = -32768;

                else if(value > 32767) value = 32767;

                outbuffer[2*j] = value;

            }





            /* Swap out the previous buffer. */

            memcpy(&q->gain_now, &q->gain_previous, sizeof(COOKgain));

            memcpy(&q->gain_previous, &q->gain_current, sizeof(COOKgain));



    } else {

        mono_decode(q, q->decode_buf_ptr[0]);



        /* Swap buffer pointers. */

        tmp_ptr = q->decode_buf_ptr[1];

        q->decode_buf_ptr[1] = q->decode_buf_ptr[0];

        q->decode_buf_ptr[0] = tmp_ptr;



        /* FIXME: Rethink the gainbuffer handling, maybe a rename?

           now/previous swap */

        q->gain_now_ptr = &q->gain_now;

        q->gain_previous_ptr = &q->gain_previous;



        cook_imlt(q, q->decode_buf_ptr[0], q->mono_mdct_output,q->mlt_tmp);

        gain_compensate(q, q->mono_mdct_output, q->gain_now_ptr,

                        q->gain_previous_ptr, q->mono_previous_buffer1);



        /* Clip and convert the floats to 16 bits */

        for (j=0 ; j<q->samples_per_frame ; j++){

            value = lrintf(q->mono_mdct_output[j]);

            if(value < -32768) value = -32768;

            else if(value > 32767) value = 32767;

            outbuffer[j] = value;

        }

        memcpy(&q->gain_now, &q->gain_previous, sizeof(COOKgain));

        memcpy(&q->gain_previous, &q->gain_current, sizeof(COOKgain));

    }

    return q->samples_per_frame * sizeof(int16_t);

}

static int decode_subpacket(COOKContext *q, uint8_t *inbuffer,

                            int sub_packet_size, int16_t *outbuffer) {

    int i,j;

    int value;

    float* tmp_ptr;



    











    decode_bytes(inbuffer, q->decoded_bytes_buffer, sub_packet_size);

    init_get_bits(&q->gb, q->decoded_bytes_buffer, sub_packet_size*8);

    decode_gain_info(&q->gb, &q->gain_current);

    memcpy(&q->gain_copy, &q->gain_current ,sizeof(COOKgain));  



    if(q->nb_channels==2 && q->joint_stereo==1){

        joint_decode(q, q->decode_buf_ptr[0], q->decode_buf_ptr[2]);



        

        tmp_ptr = q->decode_buf_ptr[1];

        q->decode_buf_ptr[1] = q->decode_buf_ptr[0];

        q->decode_buf_ptr[0] = tmp_ptr;

        tmp_ptr = q->decode_buf_ptr[3];

        q->decode_buf_ptr[3] = q->decode_buf_ptr[2];

        q->decode_buf_ptr[2] = tmp_ptr;



        



        q->gain_now_ptr = &q->gain_now;

        q->gain_previous_ptr = &q->gain_previous;

        for (i=0 ; i<q->nb_channels ; i++){



            cook_imlt(q, q->decode_buf_ptr[i*2], q->mono_mdct_output, q->mlt_tmp);

            gain_compensate(q, q->mono_mdct_output, q->gain_now_ptr,

                            q->gain_previous_ptr, q->previous_buffer_ptr[0]);



            

            tmp_ptr = q->previous_buffer_ptr[0];

            q->previous_buffer_ptr[0] = q->previous_buffer_ptr[1];

            q->previous_buffer_ptr[1] = tmp_ptr;



            

            for (j=0 ; j<q->samples_per_frame ; j++){

                value = lrintf(q->mono_mdct_output[j]);

                if(value < -32768) value = -32768;

                else if(value > 32767) value = 32767;

                outbuffer[2*j+i] = value;

            }

        }



        memcpy(&q->gain_now, &q->gain_previous, sizeof(COOKgain));

        memcpy(&q->gain_previous, &q->gain_current, sizeof(COOKgain));



    } else if (q->nb_channels==2 && q->joint_stereo==0) {

            

            mono_decode(q, q->decode_buf_ptr[0]);



            tmp_ptr = q->decode_buf_ptr[0];

            q->decode_buf_ptr[0] = q->decode_buf_ptr[1];

            q->decode_buf_ptr[1] = q->decode_buf_ptr[2];

            q->decode_buf_ptr[2] = q->decode_buf_ptr[3];

            q->decode_buf_ptr[3] = tmp_ptr;



            q->gain_now_ptr = &q->gain_now;

            q->gain_previous_ptr = &q->gain_previous;



            cook_imlt(q, q->decode_buf_ptr[0], q->mono_mdct_output,q->mlt_tmp);

            gain_compensate(q, q->mono_mdct_output, q->gain_now_ptr,

                            q->gain_previous_ptr, q->previous_buffer_ptr[0]);

            

            tmp_ptr = q->previous_buffer_ptr[0];

            q->previous_buffer_ptr[0] = q->previous_buffer_ptr[1];

            q->previous_buffer_ptr[1] = tmp_ptr;



            for (j=0 ; j<q->samples_per_frame ; j++){

                value = lrintf(q->mono_mdct_output[j]);

                if(value < -32768) value = -32768;

                else if(value > 32767) value = 32767;

                outbuffer[2*j+1] = value;

            }



            

            

            init_get_bits(&q->gb, q->decoded_bytes_buffer, sub_packet_size*8+q->bits_per_subpacket);

            decode_gain_info(&q->gb, &q->gain_current);

            

            mono_decode(q, q->decode_buf_ptr[0]);

            tmp_ptr = q->decode_buf_ptr[0];

            q->decode_buf_ptr[1] = q->decode_buf_ptr[2];

            q->decode_buf_ptr[2] = q->decode_buf_ptr[3];

            q->decode_buf_ptr[3] = tmp_ptr;



            q->gain_now_ptr = &q->gain_now;

            q->gain_previous_ptr = &q->gain_previous;



            cook_imlt(q, q->decode_buf_ptr[0], q->mono_mdct_output,q->mlt_tmp);

            gain_compensate(q, q->mono_mdct_output, q->gain_now_ptr, q->gain_previous_ptr, q->previous_buffer_ptr[0]);



            

            tmp_ptr = q->previous_buffer_ptr[0];

            q->previous_buffer_ptr[0] = q->previous_buffer_ptr[1];

            q->previous_buffer_ptr[1] = tmp_ptr;



            for (j=0 ; j<q->samples_per_frame ; j++){

                value = lrintf(q->mono_mdct_output[j]);

                if(value < -32768) value = -32768;

                else if(value > 32767) value = 32767;

                outbuffer[2*j] = value;

            }





            

            memcpy(&q->gain_now, &q->gain_previous, sizeof(COOKgain));

            memcpy(&q->gain_previous, &q->gain_current, sizeof(COOKgain));



    } else {

        mono_decode(q, q->decode_buf_ptr[0]);



        

        tmp_ptr = q->decode_buf_ptr[1];

        q->decode_buf_ptr[1] = q->decode_buf_ptr[0];

        q->decode_buf_ptr[0] = tmp_ptr;



        



        q->gain_now_ptr = &q->gain_now;

        q->gain_previous_ptr = &q->gain_previous;



        cook_imlt(q, q->decode_buf_ptr[0], q->mono_mdct_output,q->mlt_tmp);

        gain_compensate(q, q->mono_mdct_output, q->gain_now_ptr,

                        q->gain_previous_ptr, q->mono_previous_buffer1);



        

        for (j=0 ; j<q->samples_per_frame ; j++){

            value = lrintf(q->mono_mdct_output[j]);

            if(value < -32768) value = -32768;

            else if(value > 32767) value = 32767;

            outbuffer[j] = value;

        }

        memcpy(&q->gain_now, &q->gain_previous, sizeof(COOKgain));

        memcpy(&q->gain_previous, &q->gain_current, sizeof(COOKgain));

    }

    return q->samples_per_frame * sizeof(int16_t);

}

            mono_decode(q, q->decode_buf_ptr[0]);             tmp_ptr = q->decode_buf_ptr[0];             q->decode_buf_ptr[0] = q->decode_buf_ptr[1];             q->decode_buf_ptr[1] = q->decode_buf_ptr[2];             q->decode_buf_ptr[2] = q->decode_buf_ptr[3];             q->decode_buf_ptr[3] = tmp_ptr;             q->gain_now_ptr = &q->gain_now;             q->gain_previous_ptr = &q->gain_previous;             cook_imlt(q, q->decode_buf_ptr[0], q->mono_mdct_output,q->mlt_tmp);                             q->gain_previous_ptr, q->previous_buffer_ptr[0]);             tmp_ptr = q->previous_buffer_ptr[0];             q->previous_buffer_ptr[0] = q->previous_buffer_ptr[1];             q->previous_buffer_ptr[1] = tmp_ptr;             decode_gain_info(&q->gb, &q->gain_current);             tmp_ptr = q->decode_buf_ptr[0];             q->decode_buf_ptr[1] = q->decode_buf_ptr[2];             q->decode_buf_ptr[2] = q->decode_buf_ptr[3];             q->decode_buf_ptr[3] = tmp_ptr;             q->gain_now_ptr = &q->gain_now;             q->gain_previous_ptr = &q->gain_previous;             gain_compensate(q, q->mono_mdct_output, q->gain_now_ptr, q->gain_previous_ptr, q->previous_buffer_ptr[0]);             memcpy(&q->gain_now, &q->gain_previous, sizeof(COOKgain));             memcpy(&q->gain_previous, &q->gain_current, sizeof(COOKgain));
static int FUNC_0(COOKContext *VAR_0, uint8_t *VAR_1,

                            int VAR_2, int16_t *VAR_3) {

    int VAR_4,VAR_5;

    int VAR_6;

    float* VAR_7;



    











    decode_bytes(VAR_1, VAR_0->decoded_bytes_buffer, VAR_2);

    init_get_bits(&VAR_0->gb, VAR_0->decoded_bytes_buffer, VAR_2*8);

    decode_gain_info(&VAR_0->gb, &VAR_0->gain_current);

    memcpy(&VAR_0->gain_copy, &VAR_0->gain_current ,sizeof(COOKgain));  



    if(VAR_0->nb_channels==2 && VAR_0->joint_stereo==1){

        joint_decode(VAR_0, VAR_0->decode_buf_ptr[0], VAR_0->decode_buf_ptr[2]);



        

        VAR_7 = VAR_0->decode_buf_ptr[1];

        VAR_0->decode_buf_ptr[1] = VAR_0->decode_buf_ptr[0];

        VAR_0->decode_buf_ptr[0] = VAR_7;

        VAR_7 = VAR_0->decode_buf_ptr[3];

        VAR_0->decode_buf_ptr[3] = VAR_0->decode_buf_ptr[2];

        VAR_0->decode_buf_ptr[2] = VAR_7;



        



        VAR_0->gain_now_ptr = &VAR_0->gain_now;

        VAR_0->gain_previous_ptr = &VAR_0->gain_previous;

        for (VAR_4=0 ; VAR_4<VAR_0->nb_channels ; VAR_4++){



            cook_imlt(VAR_0, VAR_0->decode_buf_ptr[VAR_4*2], VAR_0->mono_mdct_output, VAR_0->mlt_tmp);

            gain_compensate(VAR_0, VAR_0->mono_mdct_output, VAR_0->gain_now_ptr,

                            VAR_0->gain_previous_ptr, VAR_0->previous_buffer_ptr[0]);



            

            VAR_7 = VAR_0->previous_buffer_ptr[0];

            VAR_0->previous_buffer_ptr[0] = VAR_0->previous_buffer_ptr[1];

            VAR_0->previous_buffer_ptr[1] = VAR_7;



            

            for (VAR_5=0 ; VAR_5<VAR_0->samples_per_frame ; VAR_5++){

                VAR_6 = lrintf(VAR_0->mono_mdct_output[VAR_5]);

                if(VAR_6 < -32768) VAR_6 = -32768;

                else if(VAR_6 > 32767) VAR_6 = 32767;

                VAR_3[2*VAR_5+VAR_4] = VAR_6;

            }

        }



        memcpy(&VAR_0->gain_now, &VAR_0->gain_previous, sizeof(COOKgain));

        memcpy(&VAR_0->gain_previous, &VAR_0->gain_current, sizeof(COOKgain));



    } else if (VAR_0->nb_channels==2 && VAR_0->joint_stereo==0) {

            

            mono_decode(VAR_0, VAR_0->decode_buf_ptr[0]);



            VAR_7 = VAR_0->decode_buf_ptr[0];

            VAR_0->decode_buf_ptr[0] = VAR_0->decode_buf_ptr[1];

            VAR_0->decode_buf_ptr[1] = VAR_0->decode_buf_ptr[2];

            VAR_0->decode_buf_ptr[2] = VAR_0->decode_buf_ptr[3];

            VAR_0->decode_buf_ptr[3] = VAR_7;



            VAR_0->gain_now_ptr = &VAR_0->gain_now;

            VAR_0->gain_previous_ptr = &VAR_0->gain_previous;



            cook_imlt(VAR_0, VAR_0->decode_buf_ptr[0], VAR_0->mono_mdct_output,VAR_0->mlt_tmp);

            gain_compensate(VAR_0, VAR_0->mono_mdct_output, VAR_0->gain_now_ptr,

                            VAR_0->gain_previous_ptr, VAR_0->previous_buffer_ptr[0]);

            

            VAR_7 = VAR_0->previous_buffer_ptr[0];

            VAR_0->previous_buffer_ptr[0] = VAR_0->previous_buffer_ptr[1];

            VAR_0->previous_buffer_ptr[1] = VAR_7;



            for (VAR_5=0 ; VAR_5<VAR_0->samples_per_frame ; VAR_5++){

                VAR_6 = lrintf(VAR_0->mono_mdct_output[VAR_5]);

                if(VAR_6 < -32768) VAR_6 = -32768;

                else if(VAR_6 > 32767) VAR_6 = 32767;

                VAR_3[2*VAR_5+1] = VAR_6;

            }



            

            

            init_get_bits(&VAR_0->gb, VAR_0->decoded_bytes_buffer, VAR_2*8+VAR_0->bits_per_subpacket);

            decode_gain_info(&VAR_0->gb, &VAR_0->gain_current);

            

            mono_decode(VAR_0, VAR_0->decode_buf_ptr[0]);

            VAR_7 = VAR_0->decode_buf_ptr[0];

            VAR_0->decode_buf_ptr[1] = VAR_0->decode_buf_ptr[2];

            VAR_0->decode_buf_ptr[2] = VAR_0->decode_buf_ptr[3];

            VAR_0->decode_buf_ptr[3] = VAR_7;



            VAR_0->gain_now_ptr = &VAR_0->gain_now;

            VAR_0->gain_previous_ptr = &VAR_0->gain_previous;



            cook_imlt(VAR_0, VAR_0->decode_buf_ptr[0], VAR_0->mono_mdct_output,VAR_0->mlt_tmp);

            gain_compensate(VAR_0, VAR_0->mono_mdct_output, VAR_0->gain_now_ptr, VAR_0->gain_previous_ptr, VAR_0->previous_buffer_ptr[0]);



            

            VAR_7 = VAR_0->previous_buffer_ptr[0];

            VAR_0->previous_buffer_ptr[0] = VAR_0->previous_buffer_ptr[1];

            VAR_0->previous_buffer_ptr[1] = VAR_7;



            for (VAR_5=0 ; VAR_5<VAR_0->samples_per_frame ; VAR_5++){

                VAR_6 = lrintf(VAR_0->mono_mdct_output[VAR_5]);

                if(VAR_6 < -32768) VAR_6 = -32768;

                else if(VAR_6 > 32767) VAR_6 = 32767;

                VAR_3[2*VAR_5] = VAR_6;

            }





            

            memcpy(&VAR_0->gain_now, &VAR_0->gain_previous, sizeof(COOKgain));

            memcpy(&VAR_0->gain_previous, &VAR_0->gain_current, sizeof(COOKgain));



    } else {

        mono_decode(VAR_0, VAR_0->decode_buf_ptr[0]);



        

        VAR_7 = VAR_0->decode_buf_ptr[1];

        VAR_0->decode_buf_ptr[1] = VAR_0->decode_buf_ptr[0];

        VAR_0->decode_buf_ptr[0] = VAR_7;



        



        VAR_0->gain_now_ptr = &VAR_0->gain_now;

        VAR_0->gain_previous_ptr = &VAR_0->gain_previous;



        cook_imlt(VAR_0, VAR_0->decode_buf_ptr[0], VAR_0->mono_mdct_output,VAR_0->mlt_tmp);

        gain_compensate(VAR_0, VAR_0->mono_mdct_output, VAR_0->gain_now_ptr,

                        VAR_0->gain_previous_ptr, VAR_0->mono_previous_buffer1);



        

        for (VAR_5=0 ; VAR_5<VAR_0->samples_per_frame ; VAR_5++){

            VAR_6 = lrintf(VAR_0->mono_mdct_output[VAR_5]);

            if(VAR_6 < -32768) VAR_6 = -32768;

            else if(VAR_6 > 32767) VAR_6 = 32767;

            VAR_3[VAR_5] = VAR_6;

        }

        memcpy(&VAR_0->gain_now, &VAR_0->gain_previous, sizeof(COOKgain));

        memcpy(&VAR_0->gain_previous, &VAR_0->gain_current, sizeof(COOKgain));

    }

    return VAR_0->samples_per_frame * sizeof(int16_t);

}

static int FUNC_0(COOKContext *VAR_0, uint8_t *VAR_1,
int VAR_2, int16_t *VAR_3) { int VAR_4,VAR_5; int VAR_6; float* VAR_7; decode_bytes(VAR_1, VAR_0->decoded_bytes_buffer, VAR_2); init_get_bits(&VAR_0->gb, VAR_0->decoded_bytes_buffer, VAR_2*8); decode_gain_info(&VAR_0->gb, &VAR_0->gain_current); memcpy(&VAR_0->gain_copy, &VAR_0->gain_current ,sizeof(COOKgain)); if(VAR_0->nb_channels==2 && VAR_0->joint_stereo==1){ joint_decode(VAR_0, VAR_0->decode_buf_ptr[0], VAR_0->decode_buf_ptr[2]); VAR_7 = VAR_0->decode_buf_ptr[1]; VAR_0->decode_buf_ptr[1] = VAR_0->decode_buf_ptr[0]; VAR_0->decode_buf_ptr[0] = VAR_7; VAR_7 = VAR_0->decode_buf_ptr[3]; VAR_0->decode_buf_ptr[3] = VAR_0->decode_buf_ptr[2]; VAR_0->decode_buf_ptr[2] = VAR_7; VAR_0->gain_now_ptr = &VAR_0->gain_now; VAR_0->gain_previous_ptr = &VAR_0->gain_previous; for (VAR_4=0 ; VAR_4<VAR_0->nb_channels ; VAR_4++){ cook_imlt(VAR_0, VAR_0->decode_buf_ptr[VAR_4*2], VAR_0->mono_mdct_output, VAR_0->mlt_tmp); gain_compensate(VAR_0, VAR_0->mono_mdct_output, VAR_0->gain_now_ptr,
VAR_0->gain_previous_ptr, VAR_0->previous_buffer_ptr[0]); VAR_7 = VAR_0->previous_buffer_ptr[0]; VAR_0->previous_buffer_ptr[0] = VAR_0->previous_buffer_ptr[1]; VAR_0->previous_buffer_ptr[1] = VAR_7; for (VAR_5=0 ; VAR_5<VAR_0->samples_per_frame ; VAR_5++){ VAR_6 = lrintf(VAR_0->mono_mdct_output[VAR_5]); if(VAR_6 < -32768) VAR_6 = -32768; else if(VAR_6 > 32767) VAR_6 = 32767; VAR_3[2*VAR_5+VAR_4] = VAR_6; } } memcpy(&VAR_0->gain_now, &VAR_0->gain_previous, sizeof(COOKgain)); memcpy(&VAR_0->gain_previous, &VAR_0->gain_current, sizeof(COOKgain)); } else if (VAR_0->nb_channels==2 && VAR_0->joint_stereo==0) { mono_decode(VAR_0, VAR_0->decode_buf_ptr[0]); VAR_7 = VAR_0->decode_buf_ptr[0]; VAR_0->decode_buf_ptr[0] = VAR_0->decode_buf_ptr[1]; VAR_0->decode_buf_ptr[1] = VAR_0->decode_buf_ptr[2]; VAR_0->decode_buf_ptr[2] = VAR_0->decode_buf_ptr[3]; VAR_0->decode_buf_ptr[3] = VAR_7; VAR_0->gain_now_ptr = &VAR_0->gain_now; VAR_0->gain_previous_ptr = &VAR_0->gain_previous; cook_imlt(VAR_0, VAR_0->decode_buf_ptr[0], VAR_0->mono_mdct_output,VAR_0->mlt_tmp); gain_compensate(VAR_0, VAR_0->mono_mdct_output, VAR_0->gain_now_ptr,
VAR_0->gain_previous_ptr, VAR_0->previous_buffer_ptr[0]); VAR_7 = VAR_0->previous_buffer_ptr[0]; VAR_0->previous_buffer_ptr[0] = VAR_0->previous_buffer_ptr[1]; VAR_0->previous_buffer_ptr[1] = VAR_7; for (VAR_5=0 ; VAR_5<VAR_0->samples_per_frame ; VAR_5++){ VAR_6 = lrintf(VAR_0->mono_mdct_output[VAR_5]); if(VAR_6 < -32768) VAR_6 = -32768; else if(VAR_6 > 32767) VAR_6 = 32767; VAR_3[2*VAR_5+1] = VAR_6; } init_get_bits(&VAR_0->gb, VAR_0->decoded_bytes_buffer, VAR_2*8+VAR_0->bits_per_subpacket); decode_gain_info(&VAR_0->gb, &VAR_0->gain_current); mono_decode(VAR_0, VAR_0->decode_buf_ptr[0]); VAR_7 = VAR_0->decode_buf_ptr[0]; VAR_0->decode_buf_ptr[1] = VAR_0->decode_buf_ptr[2]; VAR_0->decode_buf_ptr[2] = VAR_0->decode_buf_ptr[3]; VAR_0->decode_buf_ptr[3] = VAR_7; VAR_0->gain_now_ptr = &VAR_0->gain_now; VAR_0->gain_previous_ptr = &VAR_0->gain_previous; cook_imlt(VAR_0, VAR_0->decode_buf_ptr[0], VAR_0->mono_mdct_output,VAR_0->mlt_tmp); gain_compensate(VAR_0, VAR_0->mono_mdct_output, VAR_0->gain_now_ptr, VAR_0->gain_previous_ptr, VAR_0->previous_buffer_ptr[0]); VAR_7 = VAR_0->previous_buffer_ptr[0]; VAR_0->previous_buffer_ptr[0] = VAR_0->previous_buffer_ptr[1]; VAR_0->previous_buffer_ptr[1] = VAR_7; for (VAR_5=0 ; VAR_5<VAR_0->samples_per_frame ; VAR_5++){ VAR_6 = lrintf(VAR_0->mono_mdct_output[VAR_5]); if(VAR_6 < -32768) VAR_6 = -32768; else if(VAR_6 > 32767) VAR_6 = 32767; VAR_3[2*VAR_5] = VAR_6; } memcpy(&VAR_0->gain_now, &VAR_0->gain_previous, sizeof(COOKgain)); memcpy(&VAR_0->gain_previous, &VAR_0->gain_current, sizeof(COOKgain)); } else { mono_decode(VAR_0, VAR_0->decode_buf_ptr[0]); VAR_7 = VAR_0->decode_buf_ptr[1]; VAR_0->decode_buf_ptr[1] = VAR_0->decode_buf_ptr[0]; VAR_0->decode_buf_ptr[0] = VAR_7; VAR_0->gain_now_ptr = &VAR_0->gain_now; VAR_0->gain_previous_ptr = &VAR_0->gain_previous; cook_imlt(VAR_0, VAR_0->decode_buf_ptr[0], VAR_0->mono_mdct_output,VAR_0->mlt_tmp); gain_compensate(VAR_0, VAR_0->mono_mdct_output, VAR_0->gain_now_ptr,
VAR_0->gain_previous_ptr, VAR_0->mono_previous_buffer1); for (VAR_5=0 ; VAR_5<VAR_0->samples_per_frame ; VAR_5++){ VAR_6 = lrintf(VAR_0->mono_mdct_output[VAR_5]); if(VAR_6 < -32768) VAR_6 = -32768; else if(VAR_6 > 32767) VAR_6 = 32767; VAR_3[VAR_5] = VAR_6; } memcpy(&VAR_0->gain_now, &VAR_0->gain_previous, sizeof(COOKgain)); memcpy(&VAR_0->gain_previous, &VAR_0->gain_current, sizeof(COOKgain)); } return VAR_0->samples_per_frame * sizeof(int16_t); }