static int window(venc_context_t * venc, signed short * audio, int samples) {

    int i, j, channel;

    const float * win = venc->win[0];

    int window_len = 1 << (venc->blocksize[0] - 1);

    float n = (float)(1 << venc->blocksize[0]) / 4.;

    // FIXME use dsp



    if (!venc->have_saved && !samples) return 0;



    if (venc->have_saved) {

        for (channel = 0; channel < venc->channels; channel++) {

            memcpy(venc->samples + channel*window_len*2, venc->saved + channel*window_len, sizeof(float)*window_len);

        }

    } else {

        for (channel = 0; channel < venc->channels; channel++) {

            memset(venc->samples + channel*window_len*2, 0, sizeof(float)*window_len);

        }

    }



    if (samples) {

        for (channel = 0; channel < venc->channels; channel++) {

            float * offset = venc->samples + channel*window_len*2 + window_len;

            j = channel;

            for (i = 0; i < samples; i++, j += venc->channels)

                offset[i] = audio[j] / 32768. * win[window_len - i] / n;

        }

    } else {

        for (channel = 0; channel < venc->channels; channel++) {

            memset(venc->samples + channel*window_len*2 + window_len, 0, sizeof(float)*window_len);

        }

    }



    for (channel = 0; channel < venc->channels; channel++) {

        ff_mdct_calc(&venc->mdct[0], venc->coeffs + channel*window_len, venc->samples + channel*window_len*2, venc->floor/*tmp*/);

    }



    if (samples) {

        for (channel = 0; channel < venc->channels; channel++) {

            float * offset = venc->saved + channel*window_len;

            j = channel;

            for (i = 0; i < samples; i++, j += venc->channels)

                offset[i] = audio[j] / 32768. * win[i] / n;

        }

        venc->have_saved = 1;

    } else {

        venc->have_saved = 0;

    }

    return 1;

}

static int window(venc_context_t * venc, signed short * audio, int samples) {

    int i, j, channel;

    const float * win = venc->win[0];

    int window_len = 1 << (venc->blocksize[0] - 1);

    float n = (float)(1 << venc->blocksize[0]) / 4.;

    



    if (!venc->have_saved && !samples) return 0;



    if (venc->have_saved) {

        for (channel = 0; channel < venc->channels; channel++) {

            memcpy(venc->samples + channel*window_len*2, venc->saved + channel*window_len, sizeof(float)*window_len);

        }

    } else {

        for (channel = 0; channel < venc->channels; channel++) {

            memset(venc->samples + channel*window_len*2, 0, sizeof(float)*window_len);

        }

    }



    if (samples) {

        for (channel = 0; channel < venc->channels; channel++) {

            float * offset = venc->samples + channel*window_len*2 + window_len;

            j = channel;

            for (i = 0; i < samples; i++, j += venc->channels)

                offset[i] = audio[j] / 32768. * win[window_len - i] / n;

        }

    } else {

        for (channel = 0; channel < venc->channels; channel++) {

            memset(venc->samples + channel*window_len*2 + window_len, 0, sizeof(float)*window_len);

        }

    }



    for (channel = 0; channel < venc->channels; channel++) {

        ff_mdct_calc(&venc->mdct[0], venc->coeffs + channel*window_len, venc->samples + channel*window_len*2, venc->floor);

    }



    if (samples) {

        for (channel = 0; channel < venc->channels; channel++) {

            float * offset = venc->saved + channel*window_len;

            j = channel;

            for (i = 0; i < samples; i++, j += venc->channels)

                offset[i] = audio[j] / 32768. * win[i] / n;

        }

        venc->have_saved = 1;

    } else {

        venc->have_saved = 0;

    }

    return 1;

}

                offset[i] = audio[j] / 32768. * win[window_len - i] / n;                 offset[i] = audio[j] / 32768. * win[i] / n;
static int FUNC_0(venc_context_t * VAR_0, signed short * VAR_1, int VAR_2) {

    int VAR_3, VAR_4, VAR_5;

    const float * VAR_6 = VAR_0->VAR_6[0];

    int VAR_7 = 1 << (VAR_0->blocksize[0] - 1);

    float VAR_8 = (float)(1 << VAR_0->blocksize[0]) / 4.;

    



    if (!VAR_0->have_saved && !VAR_2) return 0;



    if (VAR_0->have_saved) {

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

            memcpy(VAR_0->VAR_2 + VAR_5*VAR_7*2, VAR_0->saved + VAR_5*VAR_7, sizeof(float)*VAR_7);

        }

    } else {

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

            memset(VAR_0->VAR_2 + VAR_5*VAR_7*2, 0, sizeof(float)*VAR_7);

        }

    }



    if (VAR_2) {

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

            float * offset = VAR_0->VAR_2 + VAR_5*VAR_7*2 + VAR_7;

            VAR_4 = VAR_5;

            for (VAR_3 = 0; VAR_3 < VAR_2; VAR_3++, VAR_4 += VAR_0->channels)

                offset[VAR_3] = VAR_1[VAR_4] / 32768. * VAR_6[VAR_7 - VAR_3] / VAR_8;

        }

    } else {

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

            memset(VAR_0->VAR_2 + VAR_5*VAR_7*2 + VAR_7, 0, sizeof(float)*VAR_7);

        }

    }



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

        ff_mdct_calc(&VAR_0->mdct[0], VAR_0->coeffs + VAR_5*VAR_7, VAR_0->VAR_2 + VAR_5*VAR_7*2, VAR_0->floor);

    }



    if (VAR_2) {

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

            float * offset = VAR_0->saved + VAR_5*VAR_7;

            VAR_4 = VAR_5;

            for (VAR_3 = 0; VAR_3 < VAR_2; VAR_3++, VAR_4 += VAR_0->channels)

                offset[VAR_3] = VAR_1[VAR_4] / 32768. * VAR_6[VAR_3] / VAR_8;

        }

        VAR_0->have_saved = 1;

    } else {

        VAR_0->have_saved = 0;

    }

    return 1;

}

static int FUNC_0(venc_context_t * VAR_0, signed short * VAR_1, int VAR_2) { int VAR_3, VAR_4, VAR_5; const float * VAR_6 = VAR_0->VAR_6[0]; int VAR_7 = 1 << (VAR_0->blocksize[0] - 1); float VAR_8 = (float)(1 << VAR_0->blocksize[0]) / 4.; if (!VAR_0->have_saved && !VAR_2) return 0; if (VAR_0->have_saved) { for (VAR_5 = 0; VAR_5 < VAR_0->channels; VAR_5++) { memcpy(VAR_0->VAR_2 + VAR_5*VAR_7*2, VAR_0->saved + VAR_5*VAR_7, sizeof(float)*VAR_7); } } else { for (VAR_5 = 0; VAR_5 < VAR_0->channels; VAR_5++) { memset(VAR_0->VAR_2 + VAR_5*VAR_7*2, 0, sizeof(float)*VAR_7); } } if (VAR_2) { for (VAR_5 = 0; VAR_5 < VAR_0->channels; VAR_5++) { float * offset = VAR_0->VAR_2 + VAR_5*VAR_7*2 + VAR_7; VAR_4 = VAR_5; for (VAR_3 = 0; VAR_3 < VAR_2; VAR_3++, VAR_4 += VAR_0->channels) offset[VAR_3] = VAR_1[VAR_4] / 32768. * VAR_6[VAR_7 - VAR_3] / VAR_8; } } else { for (VAR_5 = 0; VAR_5 < VAR_0->channels; VAR_5++) { memset(VAR_0->VAR_2 + VAR_5*VAR_7*2 + VAR_7, 0, sizeof(float)*VAR_7); } } for (VAR_5 = 0; VAR_5 < VAR_0->channels; VAR_5++) { ff_mdct_calc(&VAR_0->mdct[0], VAR_0->coeffs + VAR_5*VAR_7, VAR_0->VAR_2 + VAR_5*VAR_7*2, VAR_0->floor); } if (VAR_2) { for (VAR_5 = 0; VAR_5 < VAR_0->channels; VAR_5++) { float * offset = VAR_0->saved + VAR_5*VAR_7; VAR_4 = VAR_5; for (VAR_3 = 0; VAR_3 < VAR_2; VAR_3++, VAR_4 += VAR_0->channels) offset[VAR_3] = VAR_1[VAR_4] / 32768. * VAR_6[VAR_3] / VAR_8; } VAR_0->have_saved = 1; } else { VAR_0->have_saved = 0; } return 1; }