static void apply_window_mp3_c(MPA_INT *synth_buf, MPA_INT *window,
                               int *dither_state, OUT_INT *samples, int incr)
{
    register const MPA_INT *w, *w2, *p;
    int j;
    OUT_INT *samples2;
#if CONFIG_FLOAT
    float sum, sum2;
#elif FRAC_BITS <= 15
    int sum, sum2;
#else
    int64_t sum, sum2;
#endif
    memcpy(synth_buf + 512, synth_buf, 32 * sizeof(*synth_buf));
    samples2 = samples + 31 * incr;
    w = window;
    w2 = window + 31;
    sum = *dither_state;
    p = synth_buf + 16;
    SUM8(MACS, sum, w, p);
    p = synth_buf + 48;
    SUM8(MLSS, sum, w + 32, p);
    *samples = round_sample(&sum);
    samples += incr;
    w++;
    for(j=1;j<16;j++) {
        sum2 = 0;
        p = synth_buf + 16 + j;
        SUM8P2(sum, MACS, sum2, MLSS, w, w2, p);
        p = synth_buf + 48 - j;
        SUM8P2(sum, MLSS, sum2, MLSS, w + 32, w2 + 32, p);
        *samples = round_sample(&sum);
        samples += incr;
        sum += sum2;
        *samples2 = round_sample(&sum);
        samples2 -= incr;
        w++;
        w2--;
    }
    p = synth_buf + 32;
    SUM8(MLSS, sum, w + 32, p);
    *samples = round_sample(&sum);
    *dither_state= sum;
}
['static int qdm2_decode_frame(AVCodecContext *avctx,\n            void *data, int *data_size,\n            AVPacket *avpkt)\n{\n    const uint8_t *buf = avpkt->data;\n    int buf_size = avpkt->size;\n    QDM2Context *s = avctx->priv_data;\n    int16_t *out = data;\n    int i;\n    if(!buf)\n        return 0;\n    if(buf_size < s->checksum_size)\n        return -1;\n    av_log(avctx, AV_LOG_DEBUG, "decode(%d): %p[%d] -> %p[%d]\\n",\n       buf_size, buf, s->checksum_size, data, *data_size);\n    for (i = 0; i < 16; i++) {\n        if (qdm2_decode(s, buf, out) < 0)\n            return -1;\n        out += s->channels * s->frame_size;\n    }\n    *data_size = (uint8_t*)out - (uint8_t*)data;\n    return buf_size;\n}', 'static int qdm2_decode (QDM2Context *q, const uint8_t *in, int16_t *out)\n{\n    int ch, i;\n    const int frame_size = (q->frame_size * q->channels);\n    q->compressed_data = in;\n    q->compressed_size = q->checksum_size;\n    memmove(q->output_buffer, &q->output_buffer[frame_size], frame_size * sizeof(float));\n    memset(&q->output_buffer[frame_size], 0, frame_size * sizeof(float));\n    if (q->sub_packet == 0) {\n        q->has_errors = 0;\n        av_log(NULL,AV_LOG_DEBUG,"Superblock follows\\n");\n        qdm2_decode_super_block(q);\n    }\n    if (!q->has_errors) {\n        if (q->sub_packet == 2)\n            qdm2_decode_fft_packets(q);\n        qdm2_fft_tone_synthesizer(q, q->sub_packet);\n    }\n    for (ch = 0; ch < q->channels; ch++) {\n        qdm2_calculate_fft(q, ch, q->sub_packet);\n        if (!q->has_errors && q->sub_packet_list_C[0].packet != NULL) {\n            SAMPLES_NEEDED_2("has errors, and C list is not empty")\n            return -1;\n        }\n    }\n    if (!q->has_errors && q->do_synth_filter)\n        qdm2_synthesis_filter(q, q->sub_packet);\n    q->sub_packet = (q->sub_packet + 1) % 16;\n    for (i = 0; i < frame_size; i++) {\n        int value = (int)q->output_buffer[i];\n        if (value > SOFTCLIP_THRESHOLD)\n            value = (value >  HARDCLIP_THRESHOLD) ?  32767 :  softclip_table[ value - SOFTCLIP_THRESHOLD];\n        else if (value < -SOFTCLIP_THRESHOLD)\n            value = (value < -HARDCLIP_THRESHOLD) ? -32767 : -softclip_table[-value - SOFTCLIP_THRESHOLD];\n        out[i] = value;\n    }\n    return 0;\n}', 'static void qdm2_synthesis_filter (QDM2Context *q, int index)\n{\n    OUT_INT samples[MPA_MAX_CHANNELS * MPA_FRAME_SIZE];\n    int i, k, ch, sb_used, sub_sampling, dither_state = 0;\n    sb_used = QDM2_SB_USED(q->sub_sampling);\n    for (ch = 0; ch < q->channels; ch++)\n        for (i = 0; i < 8; i++)\n            for (k=sb_used; k < SBLIMIT; k++)\n                q->sb_samples[ch][(8 * index) + i][k] = 0;\n    for (ch = 0; ch < q->nb_channels; ch++) {\n        OUT_INT *samples_ptr = samples + ch;\n        for (i = 0; i < 8; i++) {\n            ff_mpa_synth_filter(q->synth_buf[ch], &(q->synth_buf_offset[ch]),\n                ff_mpa_synth_window, &dither_state,\n                samples_ptr, q->nb_channels,\n                q->sb_samples[ch][(8 * index) + i]);\n            samples_ptr += 32 * q->nb_channels;\n        }\n    }\n    sub_sampling = (4 >> q->sub_sampling);\n    for (ch = 0; ch < q->channels; ch++)\n        for (i = 0; i < q->frame_size; i++)\n            q->output_buffer[q->channels * i + ch] += (float)(samples[q->nb_channels * sub_sampling * i + ch] >> (sizeof(OUT_INT)*8-16));\n}', 'void ff_mpa_synth_filter(MPA_INT *synth_buf_ptr, int *synth_buf_offset,\n                         MPA_INT *window, int *dither_state,\n                         OUT_INT *samples, int incr,\n                         INTFLOAT sb_samples[SBLIMIT])\n{\n    register MPA_INT *synth_buf;\n    int offset;\n#if FRAC_BITS <= 15\n    int32_t tmp[32];\n    int j;\n#endif\n    offset = *synth_buf_offset;\n    synth_buf = synth_buf_ptr + offset;\n#if FRAC_BITS <= 15\n    dct32(tmp, sb_samples);\n    for(j=0;j<32;j++) {\n        synth_buf[j] = av_clip_int16(tmp[j]);\n    }\n#else\n    dct32(synth_buf, sb_samples);\n#endif\n    apply_window_mp3_c(synth_buf, window, dither_state, samples, incr);\n    offset = (offset - 32) & 511;\n    *synth_buf_offset = offset;\n}', 'static void apply_window_mp3_c(MPA_INT *synth_buf, MPA_INT *window,\n                               int *dither_state, OUT_INT *samples, int incr)\n{\n    register const MPA_INT *w, *w2, *p;\n    int j;\n    OUT_INT *samples2;\n#if CONFIG_FLOAT\n    float sum, sum2;\n#elif FRAC_BITS <= 15\n    int sum, sum2;\n#else\n    int64_t sum, sum2;\n#endif\n    memcpy(synth_buf + 512, synth_buf, 32 * sizeof(*synth_buf));\n    samples2 = samples + 31 * incr;\n    w = window;\n    w2 = window + 31;\n    sum = *dither_state;\n    p = synth_buf + 16;\n    SUM8(MACS, sum, w, p);\n    p = synth_buf + 48;\n    SUM8(MLSS, sum, w + 32, p);\n    *samples = round_sample(&sum);\n    samples += incr;\n    w++;\n    for(j=1;j<16;j++) {\n        sum2 = 0;\n        p = synth_buf + 16 + j;\n        SUM8P2(sum, MACS, sum2, MLSS, w, w2, p);\n        p = synth_buf + 48 - j;\n        SUM8P2(sum, MLSS, sum2, MLSS, w + 32, w2 + 32, p);\n        *samples = round_sample(&sum);\n        samples += incr;\n        sum += sum2;\n        *samples2 = round_sample(&sum);\n        samples2 -= incr;\n        w++;\n        w2--;\n    }\n    p = synth_buf + 32;\n    SUM8(MLSS, sum, w + 32, p);\n    *samples = round_sample(&sum);\n    *dither_state= sum;\n}']