static int apply_window_and_mdct(vorbis_enc_context *venc, int samples)
{
    int channel;
    const float * win = venc->win[0];
    int window_len = 1 << (venc->log2_blocksize[0] - 1);
    float n = (float)(1 << venc->log2_blocksize[0]) / 4.0;
    AVFloatDSPContext *fdsp = venc->fdsp;

    for (channel = 0; channel < venc->channels; channel++) {
        float *offset = venc->samples + channel * window_len * 2;

        fdsp->vector_fmul(offset, offset, win, samples);
        fdsp->vector_fmul_scalar(offset, offset, 1/n, samples);

        offset += window_len;

        fdsp->vector_fmul_reverse(offset, offset, win, samples);
        fdsp->vector_fmul_scalar(offset, offset, 1/n, samples);

        venc->mdct[0].mdct_calc(&venc->mdct[0], venc->coeffs + channel * window_len,
                     venc->samples + channel * window_len * 2);
    }
    return 1;
}