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 read_channel_data(ALSDecContext *ctx, ALSChannelData *cd, int c)\n{\n    BitstreamContext *bc    = &ctx->bc;\n    ALSChannelData *current = cd;\n    unsigned int channels   = ctx->avctx->channels;\n    int entries             = 0;\n    while (entries < channels && !(current->stop_flag = bitstream_read_bit(bc))) {\n        current->master_channel = bitstream_read(bc, av_ceil_log2(channels));\n        if (current->master_channel >= channels) {\n            av_log(ctx->avctx, AV_LOG_ERROR, "Invalid master channel!\\n");\n            return AVERROR_INVALIDDATA;\n        }\n        if (current->master_channel != c) {\n            current->time_diff_flag = bitstream_read_bit(bc);\n            current->weighting[0]   = als_weighting(bc, 1, 16);\n            current->weighting[1]   = als_weighting(bc, 2, 14);\n            current->weighting[2]   = als_weighting(bc, 1, 16);\n            if (current->time_diff_flag) {\n                current->weighting[3] = als_weighting(bc, 1, 16);\n                current->weighting[4] = als_weighting(bc, 1, 16);\n                current->weighting[5] = als_weighting(bc, 1, 16);\n                current->time_diff_sign  = bitstream_read_bit(bc);\n                current->time_diff_index = bitstream_read(bc, ctx->ltp_lag_length - 3) + 3;\n            }\n        }\n        current++;\n        entries++;\n    }\n    if (entries == channels) {\n        av_log(ctx->avctx, AV_LOG_ERROR, "Damaged channel data!\\n");\n        return AVERROR_INVALIDDATA;\n    }\n    bitstream_align(bc);\n    return 0;\n}', 'static av_always_inline av_const int av_ceil_log2_c(int x)\n{\n    return av_log2((x - 1) << 1);\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}']