static int sbr_x_gen(SpectralBandReplication *sbr, float X[2][38][64],
                     const float Y0[38][64][2], const float Y1[38][64][2],
                     const float X_low[32][40][2], int ch)
{
    int k, i;
    const int i_f = 32;
    const int i_Temp = FFMAX(2*sbr->data[ch].t_env_num_env_old - i_f, 0);
    memset(X, 0, 2*sizeof(*X));
    for (k = 0; k < sbr->kx[0]; k++) {
        for (i = 0; i < i_Temp; i++) {
            X[0][i][k] = X_low[k][i + ENVELOPE_ADJUSTMENT_OFFSET][0];
            X[1][i][k] = X_low[k][i + ENVELOPE_ADJUSTMENT_OFFSET][1];
        }
    }
    for (; k < sbr->kx[0] + sbr->m[0]; k++) {
        for (i = 0; i < i_Temp; i++) {
            X[0][i][k] = Y0[i + i_f][k][0];
            X[1][i][k] = Y0[i + i_f][k][1];
        }
    }
    for (k = 0; k < sbr->kx[1]; k++) {
        for (i = i_Temp; i < 38; i++) {
            X[0][i][k] = X_low[k][i + ENVELOPE_ADJUSTMENT_OFFSET][0];
            X[1][i][k] = X_low[k][i + ENVELOPE_ADJUSTMENT_OFFSET][1];
        }
    }
    for (; k < sbr->kx[1] + sbr->m[1]; k++) {
        for (i = i_Temp; i < i_f; i++) {
            X[0][i][k] = Y1[i][k][0];
            X[1][i][k] = Y1[i][k][1];
        }
    }
    return 0;
}
['void ff_sbr_apply(AACContext *ac, SpectralBandReplication *sbr, int id_aac,\n                  float* L, float* R)\n{\n    int downsampled = ac->m4ac.ext_sample_rate < sbr->sample_rate;\n    int ch;\n    int nch = (id_aac == TYPE_CPE) ? 2 : 1;\n    if (sbr->start) {\n        sbr_dequant(sbr, id_aac);\n    }\n    for (ch = 0; ch < nch; ch++) {\n        sbr_qmf_analysis(&ac->dsp, &sbr->mdct_ana, &sbr->dsp, ch ? R : L, sbr->data[ch].analysis_filterbank_samples,\n                         (float*)sbr->qmf_filter_scratch,\n                         sbr->data[ch].W);\n        sbr_lf_gen(ac, sbr, sbr->X_low, sbr->data[ch].W);\n        if (sbr->start) {\n            sbr_hf_inverse_filter(&sbr->dsp, sbr->alpha0, sbr->alpha1, sbr->X_low, sbr->k[0]);\n            sbr_chirp(sbr, &sbr->data[ch]);\n            sbr_hf_gen(ac, sbr, sbr->X_high, sbr->X_low, sbr->alpha0, sbr->alpha1,\n                       sbr->data[ch].bw_array, sbr->data[ch].t_env,\n                       sbr->data[ch].bs_num_env);\n            sbr_mapping(ac, sbr, &sbr->data[ch], sbr->data[ch].e_a);\n            sbr_env_estimate(sbr->e_curr, sbr->X_high, sbr, &sbr->data[ch]);\n            sbr_gain_calc(ac, sbr, &sbr->data[ch], sbr->data[ch].e_a);\n            sbr->data[ch].Ypos ^= 1;\n            sbr_hf_assemble(sbr->data[ch].Y[sbr->data[ch].Ypos],\n                            sbr->X_high, sbr, &sbr->data[ch],\n                            sbr->data[ch].e_a);\n        }\n        sbr_x_gen(sbr, sbr->X[ch],\n                  sbr->data[ch].Y[1-sbr->data[ch].Ypos],\n                  sbr->data[ch].Y[  sbr->data[ch].Ypos],\n                  sbr->X_low, ch);\n    }\n    if (ac->m4ac.ps == 1) {\n        if (sbr->ps.start) {\n            ff_ps_apply(ac->avctx, &sbr->ps, sbr->X[0], sbr->X[1], sbr->kx[1] + sbr->m[1]);\n        } else {\n            memcpy(sbr->X[1], sbr->X[0], sizeof(sbr->X[0]));\n        }\n        nch = 2;\n    }\n    sbr_qmf_synthesis(&ac->dsp, &sbr->mdct, &sbr->dsp, L, sbr->X[0], sbr->qmf_filter_scratch,\n                      sbr->data[0].synthesis_filterbank_samples,\n                      &sbr->data[0].synthesis_filterbank_samples_offset,\n                      downsampled);\n    if (nch == 2)\n        sbr_qmf_synthesis(&ac->dsp, &sbr->mdct, &sbr->dsp, R, sbr->X[1], sbr->qmf_filter_scratch,\n                          sbr->data[1].synthesis_filterbank_samples,\n                          &sbr->data[1].synthesis_filterbank_samples_offset,\n                          downsampled);\n}', 'static int sbr_x_gen(SpectralBandReplication *sbr, float X[2][38][64],\n                     const float Y0[38][64][2], const float Y1[38][64][2],\n                     const float X_low[32][40][2], int ch)\n{\n    int k, i;\n    const int i_f = 32;\n    const int i_Temp = FFMAX(2*sbr->data[ch].t_env_num_env_old - i_f, 0);\n    memset(X, 0, 2*sizeof(*X));\n    for (k = 0; k < sbr->kx[0]; k++) {\n        for (i = 0; i < i_Temp; i++) {\n            X[0][i][k] = X_low[k][i + ENVELOPE_ADJUSTMENT_OFFSET][0];\n            X[1][i][k] = X_low[k][i + ENVELOPE_ADJUSTMENT_OFFSET][1];\n        }\n    }\n    for (; k < sbr->kx[0] + sbr->m[0]; k++) {\n        for (i = 0; i < i_Temp; i++) {\n            X[0][i][k] = Y0[i + i_f][k][0];\n            X[1][i][k] = Y0[i + i_f][k][1];\n        }\n    }\n    for (k = 0; k < sbr->kx[1]; k++) {\n        for (i = i_Temp; i < 38; i++) {\n            X[0][i][k] = X_low[k][i + ENVELOPE_ADJUSTMENT_OFFSET][0];\n            X[1][i][k] = X_low[k][i + ENVELOPE_ADJUSTMENT_OFFSET][1];\n        }\n    }\n    for (; k < sbr->kx[1] + sbr->m[1]; k++) {\n        for (i = i_Temp; i < i_f; i++) {\n            X[0][i][k] = Y1[i][k][0];\n            X[1][i][k] = Y1[i][k][1];\n        }\n    }\n    return 0;\n}']