static int xan_huffman_decode(unsigned char *dest, int dest_len,
                              const unsigned char *src, int src_len)
{
    unsigned char byte = *src++;
    unsigned char ival = byte + 0x16;
    const unsigned char * ptr = src + byte*2;
    int ptr_len = src_len - 1 - byte*2;
    unsigned char val = ival;
    unsigned char *dest_end = dest + dest_len;
    unsigned char *dest_start = dest;
    GetBitContext gb;
    if (ptr_len < 0)
        return AVERROR_INVALIDDATA;
    init_get_bits(&gb, ptr, ptr_len * 8);
    while (val != 0x16) {
        unsigned idx = val - 0x17 + get_bits1(&gb) * byte;
        if (idx >= 2 * byte)
            return AVERROR_INVALIDDATA;
        val = src[idx];
        if (val < 0x16) {
            if (dest >= dest_end)
                return dest_len;
            *dest++ = val;
            val = ival;
        }
    }
    return dest - dest_start;
}
['static int xan_huffman_decode(unsigned char *dest, int dest_len,\n                              const unsigned char *src, int src_len)\n{\n    unsigned char byte = *src++;\n    unsigned char ival = byte + 0x16;\n    const unsigned char * ptr = src + byte*2;\n    int ptr_len = src_len - 1 - byte*2;\n    unsigned char val = ival;\n    unsigned char *dest_end = dest + dest_len;\n    unsigned char *dest_start = dest;\n    GetBitContext gb;\n    if (ptr_len < 0)\n        return AVERROR_INVALIDDATA;\n    init_get_bits(&gb, ptr, ptr_len * 8);\n    while (val != 0x16) {\n        unsigned idx = val - 0x17 + get_bits1(&gb) * byte;\n        if (idx >= 2 * byte)\n            return AVERROR_INVALIDDATA;\n        val = src[idx];\n        if (val < 0x16) {\n            if (dest >= dest_end)\n                return dest_len;\n            *dest++ = val;\n            val = ival;\n        }\n    }\n    return dest - dest_start;\n}', 'static inline int init_get_bits(GetBitContext *s, const uint8_t *buffer,\n                                int bit_size)\n{\n    int buffer_size;\n    int ret = 0;\n    if (bit_size > INT_MAX - 7 || bit_size < 0 || !buffer) {\n        buffer_size = bit_size = 0;\n        buffer      = NULL;\n        ret         = AVERROR_INVALIDDATA;\n    }\n    buffer_size = (bit_size + 7) >> 3;\n    s->buffer             = buffer;\n    s->size_in_bits       = bit_size;\n#if !UNCHECKED_BITSTREAM_READER\n    s->size_in_bits_plus8 = bit_size + 8;\n#endif\n    s->buffer_end         = buffer + buffer_size;\n    s->index              = 0;\n    return ret;\n}', 'static inline unsigned int get_bits1(GetBitContext *s)\n{\n    unsigned int index = s->index;\n    uint8_t result     = s->buffer[index >> 3];\n#ifdef BITSTREAM_READER_LE\n    result >>= index & 7;\n    result  &= 1;\n#else\n    result <<= index & 7;\n    result >>= 8 - 1;\n#endif\n#if !UNCHECKED_BITSTREAM_READER\n    if (s->index < s->size_in_bits_plus8)\n#endif\n        index++;\n    s->index = index;\n    return result;\n}']