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 adx_decode(ADXContext *c, int16_t *out, int offset,\n                      const uint8_t *in, int ch)\n{\n    ADXChannelState *prev = &c->prev[ch];\n    BitstreamContext bc;\n    int scale = AV_RB16(in);\n    int i;\n    int s0, s1, s2, d;\n    if (scale & 0x8000)\n        return -1;\n    bitstream_init(&bc, in + 2, (BLOCK_SIZE - 2) * 8);\n    out += offset;\n    s1 = prev->s1;\n    s2 = prev->s2;\n    for (i = 0; i < BLOCK_SAMPLES; i++) {\n        d  = bitstream_read_signed(&bc, 4);\n        s0 = ((d << COEFF_BITS) * scale + c->coeff[0] * s1 + c->coeff[1] * s2) >> COEFF_BITS;\n        s2 = s1;\n        s1 = av_clip_int16(s0);\n        *out++ = s1;\n    }\n    prev->s1 = s1;\n    prev->s2 = s2;\n    return 0;\n}', 'static inline int32_t bitstream_read_signed(BitstreamContext *bc, unsigned n)\n{\n    return sign_extend(bitstream_read(bc, n), n);\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 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}']