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;
}
['void avpriv_tak_parse_streaminfo(BitstreamContext *bc, TAKStreamInfo *s)\n{\n    uint64_t channel_mask = 0;\n    int frame_type, i;\n    s->codec = bitstream_read(bc, TAK_ENCODER_CODEC_BITS);\n    bitstream_skip(bc, TAK_ENCODER_PROFILE_BITS);\n    frame_type = bitstream_read(bc, TAK_SIZE_FRAME_DURATION_BITS);\n    s->samples = bitstream_read_63(bc, TAK_SIZE_SAMPLES_NUM_BITS);\n    s->data_type   = bitstream_read(bc, TAK_FORMAT_DATA_TYPE_BITS);\n    s->sample_rate = bitstream_read(bc, TAK_FORMAT_SAMPLE_RATE_BITS) +\n                     TAK_SAMPLE_RATE_MIN;\n    s->bps         = bitstream_read(bc, TAK_FORMAT_BPS_BITS) +\n                     TAK_BPS_MIN;\n    s->channels    = bitstream_read(bc, TAK_FORMAT_CHANNEL_BITS) +\n                     TAK_CHANNELS_MIN;\n    if (bitstream_read_bit(bc)) {\n        bitstream_skip(bc, TAK_FORMAT_VALID_BITS);\n        if (bitstream_read_bit(bc)) {\n            for (i = 0; i < s->channels; i++) {\n                int value = bitstream_read(bc, TAK_FORMAT_CH_LAYOUT_BITS);\n                if (value > 0 && value <= 18)\n                    channel_mask |= 1 << (value - 1);\n            }\n        }\n    }\n    s->ch_layout     = channel_mask;\n    s->frame_samples = tak_get_nb_samples(s->sample_rate, frame_type);\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 bitstream_read_63(BitstreamContext *bc, unsigned n)\n{\n    uint64_t ret = 0;\n#ifdef BITSTREAM_READER_LE\n    uint64_t left = 0;\n#endif\n    if (!n)\n        return 0;\n    if (n > bc->bits_left) {\n        n -= bc->bits_left;\n#ifdef BITSTREAM_READER_LE\n        left = bc->bits_left;\n#endif\n        ret = get_val(bc, bc->bits_left);\n        refill_64(bc);\n    }\n#ifdef BITSTREAM_READER_LE\n    ret = get_val(bc, n) << left | ret;\n#else\n    ret = get_val(bc, n) | ret << n;\n#endif\n    return ret;\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}']