static void dequant_lsps(double *lsps, int num,
                         const uint16_t *values,
                         const uint16_t *sizes,
                         int n_stages, const uint8_t *table,
                         const double *mul_q,
                         const double *base_q)
{
    int n, m;
    memset(lsps, 0, num * sizeof(*lsps));
    for (n = 0; n < n_stages; n++) {
        const uint8_t *t_off = &table[values[n] * num];
        double base = base_q[n], mul = mul_q[n];
        for (m = 0; m < num; m++)
            lsps[m] += base + mul * t_off[m];
        table += sizes[n] * num;
    }
}
['static int synth_superframe(AVCodecContext *ctx, AVFrame *frame,\n                            int *got_frame_ptr)\n{\n    WMAVoiceContext *s = ctx->priv_data;\n    GetBitContext *gb = &s->gb, s_gb;\n    int n, res, n_samples = 480;\n    double lsps[MAX_FRAMES][MAX_LSPS];\n    const double *mean_lsf = s->lsps == 16 ?\n        wmavoice_mean_lsf16[s->lsp_def_mode] : wmavoice_mean_lsf10[s->lsp_def_mode];\n    float excitation[MAX_SIGNAL_HISTORY + MAX_SFRAMESIZE + 12];\n    float synth[MAX_LSPS + MAX_SFRAMESIZE];\n    float *samples;\n    memcpy(synth,      s->synth_history,\n           s->lsps             * sizeof(*synth));\n    memcpy(excitation, s->excitation_history,\n           s->history_nsamples * sizeof(*excitation));\n    if (s->sframe_cache_size > 0) {\n        gb = &s_gb;\n        init_get_bits(gb, s->sframe_cache, s->sframe_cache_size);\n        s->sframe_cache_size = 0;\n    }\n    if ((res = check_bits_for_superframe(gb, s)) == 1) {\n        *got_frame_ptr = 0;\n        return 1;\n    }\n    if (!get_bits1(gb)) {\n        av_log_missing_feature(ctx, "WMAPro-in-WMAVoice", 1);\n        return AVERROR_PATCHWELCOME;\n    }\n    if (get_bits1(gb)) {\n        if ((n_samples = get_bits(gb, 12)) > 480) {\n            av_log(ctx, AV_LOG_ERROR,\n                   "Superframe encodes >480 samples (%d), not allowed\\n",\n                   n_samples);\n            return -1;\n        }\n    }\n    if (s->has_residual_lsps) {\n        double prev_lsps[MAX_LSPS], a1[MAX_LSPS * 2], a2[MAX_LSPS * 2];\n        for (n = 0; n < s->lsps; n++)\n            prev_lsps[n] = s->prev_lsps[n] - mean_lsf[n];\n        if (s->lsps == 10) {\n            dequant_lsp10r(gb, lsps[2], prev_lsps, a1, a2, s->lsp_q_mode);\n        } else\n            dequant_lsp16r(gb, lsps[2], prev_lsps, a1, a2, s->lsp_q_mode);\n        for (n = 0; n < s->lsps; n++) {\n            lsps[0][n]  = mean_lsf[n] + (a1[n]           - a2[n * 2]);\n            lsps[1][n]  = mean_lsf[n] + (a1[s->lsps + n] - a2[n * 2 + 1]);\n            lsps[2][n] += mean_lsf[n];\n        }\n        for (n = 0; n < 3; n++)\n            stabilize_lsps(lsps[n], s->lsps);\n    }\n    frame->nb_samples = 480;\n    if ((res = ff_get_buffer(ctx, frame)) < 0) {\n        av_log(ctx, AV_LOG_ERROR, "get_buffer() failed\\n");\n        return res;\n    }\n    frame->nb_samples = n_samples;\n    samples = (float *)frame->data[0];\n    for (n = 0; n < 3; n++) {\n        if (!s->has_residual_lsps) {\n            int m;\n            if (s->lsps == 10) {\n                dequant_lsp10i(gb, lsps[n]);\n            } else\n                dequant_lsp16i(gb, lsps[n]);\n            for (m = 0; m < s->lsps; m++)\n                lsps[n][m] += mean_lsf[m];\n            stabilize_lsps(lsps[n], s->lsps);\n        }\n        if ((res = synth_frame(ctx, gb, n,\n                               &samples[n * MAX_FRAMESIZE],\n                               lsps[n], n == 0 ? s->prev_lsps : lsps[n - 1],\n                               &excitation[s->history_nsamples + n * MAX_FRAMESIZE],\n                               &synth[s->lsps + n * MAX_FRAMESIZE]))) {\n            *got_frame_ptr = 0;\n            return res;\n        }\n    }\n    if (get_bits1(gb)) {\n        res = get_bits(gb, 4);\n        skip_bits(gb, 10 * (res + 1));\n    }\n    *got_frame_ptr = 1;\n    memcpy(s->prev_lsps,           lsps[2],\n           s->lsps             * sizeof(*s->prev_lsps));\n    memcpy(s->synth_history,      &synth[MAX_SFRAMESIZE],\n           s->lsps             * sizeof(*synth));\n    memcpy(s->excitation_history, &excitation[MAX_SFRAMESIZE],\n           s->history_nsamples * sizeof(*excitation));\n    if (s->do_apf)\n        memmove(s->zero_exc_pf,       &s->zero_exc_pf[MAX_SFRAMESIZE],\n                s->history_nsamples * sizeof(*s->zero_exc_pf));\n    return 0;\n}', 'static void dequant_lsp10r(GetBitContext *gb,\n                           double *i_lsps, const double *old,\n                           double *a1, double *a2, int q_mode)\n{\n    static const uint16_t vec_sizes[3] = { 128, 64, 64 };\n    static const double mul_lsf[3] = {\n        2.5807601174e-3,    1.2354460219e-3,   1.1763821673e-3\n    };\n    static const double base_lsf[3] = {\n        M_PI * -1.07448e-1, M_PI * -5.2706e-2, M_PI * -5.1634e-2\n    };\n    const float (*ipol_tab)[2][10] = q_mode ?\n        wmavoice_lsp10_intercoeff_b : wmavoice_lsp10_intercoeff_a;\n    uint16_t interpol, v[3];\n    int n;\n    dequant_lsp10i(gb, i_lsps);\n    interpol = get_bits(gb, 5);\n    v[0]     = get_bits(gb, 7);\n    v[1]     = get_bits(gb, 6);\n    v[2]     = get_bits(gb, 6);\n    for (n = 0; n < 10; n++) {\n        double delta = old[n] - i_lsps[n];\n        a1[n]        = ipol_tab[interpol][0][n] * delta + i_lsps[n];\n        a1[10 + n]   = ipol_tab[interpol][1][n] * delta + i_lsps[n];\n    }\n    dequant_lsps(a2, 20, v, vec_sizes, 3, wmavoice_dq_lsp10r,\n                 mul_lsf, base_lsf);\n}', 'static void dequant_lsp10i(GetBitContext *gb, double *lsps)\n{\n    static const uint16_t vec_sizes[4] = { 256, 64, 32, 32 };\n    static const double mul_lsf[4] = {\n        5.2187144800e-3,    1.4626986422e-3,\n        9.6179549166e-4,    1.1325736225e-3\n    };\n    static const double base_lsf[4] = {\n        M_PI * -2.15522e-1, M_PI * -6.1646e-2,\n        M_PI * -3.3486e-2,  M_PI * -5.7408e-2\n    };\n    uint16_t v[4];\n    v[0] = get_bits(gb, 8);\n    v[1] = get_bits(gb, 6);\n    v[2] = get_bits(gb, 5);\n    v[3] = get_bits(gb, 5);\n    dequant_lsps(lsps, 10, v, vec_sizes, 4, wmavoice_dq_lsp10i,\n                 mul_lsf, base_lsf);\n}', 'static void dequant_lsps(double *lsps, int num,\n                         const uint16_t *values,\n                         const uint16_t *sizes,\n                         int n_stages, const uint8_t *table,\n                         const double *mul_q,\n                         const double *base_q)\n{\n    int n, m;\n    memset(lsps, 0, num * sizeof(*lsps));\n    for (n = 0; n < n_stages; n++) {\n        const uint8_t *t_off = &table[values[n] * num];\n        double base = base_q[n], mul = mul_q[n];\n        for (m = 0; m < num; m++)\n            lsps[m] += base + mul * t_off[m];\n        table += sizes[n] * num;\n    }\n}']