static inline uint64_t get_val(BitstreamContext *bc, unsigned n)
{
#ifdef BITSTREAM_READER_LE
    uint64_t ret = bc->bits & ((UINT64_C(1) << n) - 1);
    bc->bits >>= n;
#else
    uint64_t ret = bc->bits >> (64 - n);
    bc->bits <<= n;
#endif
    bc->bits_left -= n;
    return ret;
}
['static int decorrelate(TAKDecContext *s, int c1, int c2, int length)\n{\n    BitstreamContext *bc = &s->bc;\n    int32_t *p1       = s->decoded[c1] + 1;\n    int32_t *p2       = s->decoded[c2] + 1;\n    int i;\n    int dshift, dfactor;\n    switch (s->dmode) {\n    case 1:\n        for (i = 0; i < length; i++) {\n            int32_t a = p1[i];\n            int32_t b = p2[i];\n            p2[i]     = a + b;\n        }\n        break;\n    case 2:\n        for (i = 0; i < length; i++) {\n            int32_t a = p1[i];\n            int32_t b = p2[i];\n            p1[i]     = b - a;\n        }\n        break;\n    case 3:\n        for (i = 0; i < length; i++) {\n            int32_t a = p1[i];\n            int32_t b = p2[i];\n            a        -= b >> 1;\n            p1[i]     = a;\n            p2[i]     = a + b;\n        }\n        break;\n    case 4:\n        FFSWAP(int32_t*, p1, p2);\n    case 5:\n        dshift  = bits_esc4(bc);\n        dfactor = bitstream_read_signed(bc, 10);\n        for (i = 0; i < length; i++) {\n            int32_t a = p1[i];\n            int32_t b = p2[i];\n            b         = dfactor * (b >> dshift) + 128 >> 8 << dshift;\n            p1[i]     = b - a;\n        }\n        break;\n    case 6:\n        FFSWAP(int32_t*, p1, p2);\n    case 7: {\n        LOCAL_ALIGNED_16(int16_t, filter, [MAX_PREDICTORS]);\n        int length2, order_half, filter_order, dval1, dval2;\n        int av_uninit(code_size);\n        memset(filter, 0, MAX_PREDICTORS * sizeof(*filter));\n        if (length < 256)\n            return AVERROR_INVALIDDATA;\n        dshift       = bits_esc4(bc);\n        filter_order = 8 << bitstream_read_bit(bc);\n        dval1        = bitstream_read_bit(bc);\n        dval2        = bitstream_read_bit(bc);\n        for (i = 0; i < filter_order; i++) {\n            if (!(i & 3))\n                code_size = 14 - bitstream_read(bc, 3);\n            filter[i] = bitstream_read_signed(bc, code_size);\n        }\n        order_half = filter_order / 2;\n        length2    = length - (filter_order - 1);\n        if (dval1) {\n            for (i = 0; i < order_half; i++) {\n                int32_t a = p1[i];\n                int32_t b = p2[i];\n                p1[i]     = a + b;\n            }\n        }\n        if (dval2) {\n            for (i = length2 + order_half; i < length; i++) {\n                int32_t a = p1[i];\n                int32_t b = p2[i];\n                p1[i]     = a + b;\n            }\n        }\n        av_fast_malloc(&s->residues, &s->residues_buf_size,\n                       FFALIGN(length + 16, 16) * sizeof(*s->residues));\n        if (!s->residues)\n            return AVERROR(ENOMEM);\n        memset(s->residues, 0, s->residues_buf_size);\n        for (i = 0; i < length; i++)\n            s->residues[i] = p2[i] >> dshift;\n        p1 += order_half;\n        for (i = 0; i < length2; i++) {\n            int v = 1 << 9;\n            v += s->adsp.scalarproduct_int16(&s->residues[i], filter,\n                                             FFALIGN(filter_order, 16));\n            p1[i] = (av_clip_intp2(v >> 10, 13) << dshift) - p1[i];\n        }\n        emms_c();\n        break;\n    }\n    }\n    return 0;\n}', 'static int bits_esc4(BitstreamContext *bc)\n{\n    if (bitstream_read_bit(bc))\n        return bitstream_read(bc, 4) + 1;\n    else\n        return 0;\n}', 'static inline uint32_t bitstream_read(BitstreamContext *bc, unsigned n)\n{\n    if (!n)\n        return 0;\n    if (n > bc->bits_left) {\n        refill_32(bc);\n        if (bc->bits_left < 32)\n            bc->bits_left = n;\n    }\n    return get_val(bc, n);\n}', 'static inline unsigned bitstream_read_bit(BitstreamContext *bc)\n{\n    if (!bc->bits_left)\n        refill_64(bc);\n    return get_val(bc, 1);\n}', 'static inline uint64_t get_val(BitstreamContext *bc, unsigned n)\n{\n#ifdef BITSTREAM_READER_LE\n    uint64_t ret = bc->bits & ((UINT64_C(1) << n) - 1);\n    bc->bits >>= n;\n#else\n    uint64_t ret = bc->bits >> (64 - n);\n    bc->bits <<= n;\n#endif\n    bc->bits_left -= n;\n    return ret;\n}']