/* Out-of-line code for Huffman code decoding. See jdhuff.h for info about usage.  */
jpeg_huff_decode(bitread_working_state *state, register bit_buf_type get_buffer, register int bits_left, d_derived_tbl *htbl, int min_bits)
/* Out-of-line code for Huffman code decoding. See jdhuff.h for info about usage.  */
jpeg_huff_decode(bitread_working_state *state, register bit_buf_type get_buffer, register int bits_left, d_derived_tbl *htbl, int min_bits)
{
    register int l = min_bits;
    register CLR_INT32 code;
    CHECK_BIT_BUFFER(*state, l, return -1);
    code = GET_BITS(l);
    while (code > htbl->maxcode[l]) {
        code <<= 1;
        CHECK_BIT_BUFFER(*state, 1, return -1);
        code |= GET_BITS(1);
        l++;
    }
    state->get_buffer = get_buffer;
    state->bits_left = bits_left;
    if (l > 16) {
        WARNMS(state->cinfo, JWRN_HUFF_BAD_CODE);
        return 0;
    }
    return htbl->pub->huffval[(int)(code + htbl->valoffset[l])];
}