static int vorbis_residue_decode(vorbis_context *vc, vorbis_residue *vr, uint_fast8_t ch, uint_fast8_t *do_not_decode, float *vec, uint_fast16_t vlen) {
    GetBitContext *gb=&vc->gb;
    uint_fast8_t c_p_c=vc->codebooks[vr->classbook].dimensions;
    uint_fast16_t n_to_read=vr->end-vr->begin;
    uint_fast16_t ptns_to_read=n_to_read/vr->partition_size;
    uint_fast8_t classifs[ptns_to_read*vc->audio_channels];
    uint_fast8_t pass;
    uint_fast8_t ch_used;
    uint_fast8_t i,j,l;
    uint_fast16_t k;
    if (vr->type==2) {
        for(j=1;j<ch;++j) {
                do_not_decode[0]&=do_not_decode[j];
        }
        if (do_not_decode[0]) return 0;
        ch_used=1;
    } else {
        ch_used=ch;
    }
    AV_DEBUG(" residue type 0/1/2 decode begin, ch: %d  cpc %d  \n", ch, c_p_c);
    for(pass=0;pass<=vr->maxpass;++pass) {
        uint_fast16_t voffset;
        uint_fast16_t partition_count;
        uint_fast16_t j_times_ptns_to_read;
        voffset=vr->begin;
        for(partition_count=0;partition_count<ptns_to_read;) {
            if (!pass) {
                uint_fast32_t inverse_class = ff_inverse[vr->classifications];
                for(j_times_ptns_to_read=0, j=0;j<ch_used;++j) {
                    if (!do_not_decode[j]) {
                        uint_fast32_t temp=get_vlc2(gb, vc->codebooks[vr->classbook].vlc.table,
                        vc->codebooks[vr->classbook].nb_bits, 3);
                        AV_DEBUG("Classword: %d \n", temp);
                        assert(vr->classifications > 1 && temp<=65536);
                        for(i=0;i<c_p_c;++i) {
                            uint_fast32_t temp2;
                            temp2=(((uint_fast64_t)temp) * inverse_class)>>32;
                            if (partition_count+c_p_c-1-i < ptns_to_read) {
                                classifs[j_times_ptns_to_read+partition_count+c_p_c-1-i]=temp-temp2*vr->classifications;
                            }
                            temp=temp2;
                        }
                    }
                    j_times_ptns_to_read+=ptns_to_read;
                }
            }
            for(i=0;(i<c_p_c) && (partition_count<ptns_to_read);++i) {
                for(j_times_ptns_to_read=0, j=0;j<ch_used;++j) {
                    uint_fast16_t voffs;
                    if (!do_not_decode[j]) {
                        uint_fast8_t vqclass=classifs[j_times_ptns_to_read+partition_count];
                        int_fast16_t vqbook=vr->books[vqclass][pass];
                        if (vqbook>=0 && vc->codebooks[vqbook].codevectors) {
                            uint_fast16_t coffs;
                            unsigned dim= vc->codebooks[vqbook].dimensions;
                            uint_fast16_t step= dim==1 ? vr->partition_size
                                              : FASTDIV(vr->partition_size, dim);
                            vorbis_codebook codebook= vc->codebooks[vqbook];
                            if (vr->type==0) {
                                voffs=voffset+j*vlen;
                                for(k=0;k<step;++k) {
                                    coffs=get_vlc2(gb, codebook.vlc.table, codebook.nb_bits, 3) * dim;
                                    for(l=0;l<dim;++l) {
                                        vec[voffs+k+l*step]+=codebook.codevectors[coffs+l];
                                    }
                                }
                            }
                            else if (vr->type==1) {
                                voffs=voffset+j*vlen;
                                for(k=0;k<step;++k) {
                                    coffs=get_vlc2(gb, codebook.vlc.table, codebook.nb_bits, 3) * dim;
                                    for(l=0;l<dim;++l, ++voffs) {
                                        vec[voffs]+=codebook.codevectors[coffs+l];
                                        AV_DEBUG(" pass %d offs: %d curr: %f change: %f cv offs.: %d  \n", pass, voffs, vec[voffs], codebook.codevectors[coffs+l], coffs);
                                    }
                                }
                            }
                            else if (vr->type==2 && ch==2 && (voffset&1)==0 && (dim&1)==0) {
                                voffs=voffset>>1;
                                if(dim==2) {
                                    for(k=0;k<step;++k) {
                                        coffs=get_vlc2(gb, codebook.vlc.table, codebook.nb_bits, 3) * 2;
                                        vec[voffs+k     ]+=codebook.codevectors[coffs  ];
                                        vec[voffs+k+vlen]+=codebook.codevectors[coffs+1];
                                    }
                                } else
                                for(k=0;k<step;++k) {
                                    coffs=get_vlc2(gb, codebook.vlc.table, codebook.nb_bits, 3) * dim;
                                    for(l=0;l<dim;l+=2, voffs++) {
                                        vec[voffs     ]+=codebook.codevectors[coffs+l  ];
                                        vec[voffs+vlen]+=codebook.codevectors[coffs+l+1];
                                        AV_DEBUG(" pass %d offs: %d curr: %f change: %f cv offs.: %d+%d  \n", pass, voffset/ch+(voffs%ch)*vlen, vec[voffset/ch+(voffs%ch)*vlen], codebook.codevectors[coffs+l], coffs, l);
                                    }
                                }
                            }
                            else if (vr->type==2) {
                                voffs=voffset;
                                for(k=0;k<step;++k) {
                                    coffs=get_vlc2(gb, codebook.vlc.table, codebook.nb_bits, 3) * dim;
                                    for(l=0;l<dim;++l, ++voffs) {
                                        vec[voffs/ch+(voffs%ch)*vlen]+=codebook.codevectors[coffs+l];
                                        AV_DEBUG(" pass %d offs: %d curr: %f change: %f cv offs.: %d+%d  \n", pass, voffset/ch+(voffs%ch)*vlen, vec[voffset/ch+(voffs%ch)*vlen], codebook.codevectors[coffs+l], coffs, l);
                                    }
                                }
                            } else {
                                av_log(vc->avccontext, AV_LOG_ERROR, " Invalid residue type while residue decode?! \n");
                                return 1;
                            }
                        }
                    }
                    j_times_ptns_to_read+=ptns_to_read;
                }
                ++partition_count;
                voffset+=vr->partition_size;
            }
        }
    }
    return 0;
}
['static int vorbis_residue_decode(vorbis_context *vc, vorbis_residue *vr, uint_fast8_t ch, uint_fast8_t *do_not_decode, float *vec, uint_fast16_t vlen) {\n    GetBitContext *gb=&vc->gb;\n    uint_fast8_t c_p_c=vc->codebooks[vr->classbook].dimensions;\n    uint_fast16_t n_to_read=vr->end-vr->begin;\n    uint_fast16_t ptns_to_read=n_to_read/vr->partition_size;\n    uint_fast8_t classifs[ptns_to_read*vc->audio_channels];\n    uint_fast8_t pass;\n    uint_fast8_t ch_used;\n    uint_fast8_t i,j,l;\n    uint_fast16_t k;\n    if (vr->type==2) {\n        for(j=1;j<ch;++j) {\n                do_not_decode[0]&=do_not_decode[j];\n        }\n        if (do_not_decode[0]) return 0;\n        ch_used=1;\n    } else {\n        ch_used=ch;\n    }\n    AV_DEBUG(" residue type 0/1/2 decode begin, ch: %d  cpc %d  \\n", ch, c_p_c);\n    for(pass=0;pass<=vr->maxpass;++pass) {\n        uint_fast16_t voffset;\n        uint_fast16_t partition_count;\n        uint_fast16_t j_times_ptns_to_read;\n        voffset=vr->begin;\n        for(partition_count=0;partition_count<ptns_to_read;) {\n            if (!pass) {\n                uint_fast32_t inverse_class = ff_inverse[vr->classifications];\n                for(j_times_ptns_to_read=0, j=0;j<ch_used;++j) {\n                    if (!do_not_decode[j]) {\n                        uint_fast32_t temp=get_vlc2(gb, vc->codebooks[vr->classbook].vlc.table,\n                        vc->codebooks[vr->classbook].nb_bits, 3);\n                        AV_DEBUG("Classword: %d \\n", temp);\n                        assert(vr->classifications > 1 && temp<=65536);\n                        for(i=0;i<c_p_c;++i) {\n                            uint_fast32_t temp2;\n                            temp2=(((uint_fast64_t)temp) * inverse_class)>>32;\n                            if (partition_count+c_p_c-1-i < ptns_to_read) {\n                                classifs[j_times_ptns_to_read+partition_count+c_p_c-1-i]=temp-temp2*vr->classifications;\n                            }\n                            temp=temp2;\n                        }\n                    }\n                    j_times_ptns_to_read+=ptns_to_read;\n                }\n            }\n            for(i=0;(i<c_p_c) && (partition_count<ptns_to_read);++i) {\n                for(j_times_ptns_to_read=0, j=0;j<ch_used;++j) {\n                    uint_fast16_t voffs;\n                    if (!do_not_decode[j]) {\n                        uint_fast8_t vqclass=classifs[j_times_ptns_to_read+partition_count];\n                        int_fast16_t vqbook=vr->books[vqclass][pass];\n                        if (vqbook>=0 && vc->codebooks[vqbook].codevectors) {\n                            uint_fast16_t coffs;\n                            unsigned dim= vc->codebooks[vqbook].dimensions;\n                            uint_fast16_t step= dim==1 ? vr->partition_size\n                                              : FASTDIV(vr->partition_size, dim);\n                            vorbis_codebook codebook= vc->codebooks[vqbook];\n                            if (vr->type==0) {\n                                voffs=voffset+j*vlen;\n                                for(k=0;k<step;++k) {\n                                    coffs=get_vlc2(gb, codebook.vlc.table, codebook.nb_bits, 3) * dim;\n                                    for(l=0;l<dim;++l) {\n                                        vec[voffs+k+l*step]+=codebook.codevectors[coffs+l];\n                                    }\n                                }\n                            }\n                            else if (vr->type==1) {\n                                voffs=voffset+j*vlen;\n                                for(k=0;k<step;++k) {\n                                    coffs=get_vlc2(gb, codebook.vlc.table, codebook.nb_bits, 3) * dim;\n                                    for(l=0;l<dim;++l, ++voffs) {\n                                        vec[voffs]+=codebook.codevectors[coffs+l];\n                                        AV_DEBUG(" pass %d offs: %d curr: %f change: %f cv offs.: %d  \\n", pass, voffs, vec[voffs], codebook.codevectors[coffs+l], coffs);\n                                    }\n                                }\n                            }\n                            else if (vr->type==2 && ch==2 && (voffset&1)==0 && (dim&1)==0) {\n                                voffs=voffset>>1;\n                                if(dim==2) {\n                                    for(k=0;k<step;++k) {\n                                        coffs=get_vlc2(gb, codebook.vlc.table, codebook.nb_bits, 3) * 2;\n                                        vec[voffs+k     ]+=codebook.codevectors[coffs  ];\n                                        vec[voffs+k+vlen]+=codebook.codevectors[coffs+1];\n                                    }\n                                } else\n                                for(k=0;k<step;++k) {\n                                    coffs=get_vlc2(gb, codebook.vlc.table, codebook.nb_bits, 3) * dim;\n                                    for(l=0;l<dim;l+=2, voffs++) {\n                                        vec[voffs     ]+=codebook.codevectors[coffs+l  ];\n                                        vec[voffs+vlen]+=codebook.codevectors[coffs+l+1];\n                                        AV_DEBUG(" pass %d offs: %d curr: %f change: %f cv offs.: %d+%d  \\n", pass, voffset/ch+(voffs%ch)*vlen, vec[voffset/ch+(voffs%ch)*vlen], codebook.codevectors[coffs+l], coffs, l);\n                                    }\n                                }\n                            }\n                            else if (vr->type==2) {\n                                voffs=voffset;\n                                for(k=0;k<step;++k) {\n                                    coffs=get_vlc2(gb, codebook.vlc.table, codebook.nb_bits, 3) * dim;\n                                    for(l=0;l<dim;++l, ++voffs) {\n                                        vec[voffs/ch+(voffs%ch)*vlen]+=codebook.codevectors[coffs+l];\n                                        AV_DEBUG(" pass %d offs: %d curr: %f change: %f cv offs.: %d+%d  \\n", pass, voffset/ch+(voffs%ch)*vlen, vec[voffset/ch+(voffs%ch)*vlen], codebook.codevectors[coffs+l], coffs, l);\n                                    }\n                                }\n                            } else {\n                                av_log(vc->avccontext, AV_LOG_ERROR, " Invalid residue type while residue decode?! \\n");\n                                return 1;\n                            }\n                        }\n                    }\n                    j_times_ptns_to_read+=ptns_to_read;\n                }\n                ++partition_count;\n                voffset+=vr->partition_size;\n            }\n        }\n    }\n    return 0;\n}']