Re-factor and re-license under the libjpeg BSD-style license. Justification: the accelerated Huffman decoding optimizations in libjpeg-turbo were all developed by me as an independent developer. The structure of the inline Huffman decoding macros was originally borrowed from similar routines in the TurboJPEG/mediaLib codec, which is part of VirtualGL and TurboVNC. Thus, although the code for these macros was not copied verbatim, they were still thought to be a derivative work of TurboJPEG/mediaLib, and I assigned the copyright and license from TurboJPEG/mediaLib to them. I have re-written these routines from first principles by breaking down the libjpeg out-of-line routines. Although the new code bears algorithmic similarities to the TurboJPEG/mediaLib macros, it can now clearly be shown to be derived from the out-of-line routines and thus, in my opinion, it can no longer be considered a derivative of TurboJPEG/mediaLib. -- DRC
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@590 632fc199-4ca6-4c93-a231-07263d6284db
diff --git a/jdhuff.h b/jdhuff.h
index 2697488..96f2dab 100644
--- a/jdhuff.h
+++ b/jdhuff.h
@@ -2,7 +2,7 @@
* jdhuff.h
*
* Copyright (C) 1991-1997, Thomas G. Lane.
- * Copyright (C) 2010, D. R. Commander.
+ * Copyright (C) 2010-2011, D. R. Commander.
* This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file.
*
@@ -208,6 +208,26 @@
} \
}
+#define HUFF_DECODE_FAST(s,nb,htbl) \
+ FILL_BIT_BUFFER_FAST; \
+ s = PEEK_BITS(HUFF_LOOKAHEAD); \
+ s = htbl->lookup[s]; \
+ nb = s >> HUFF_LOOKAHEAD; \
+ /* Pre-execute the common case of nb <= HUFF_LOOKAHEAD */ \
+ DROP_BITS(nb); \
+ s = s & ((1 << HUFF_LOOKAHEAD) - 1); \
+ if (nb > HUFF_LOOKAHEAD) { \
+ /* Equivalent of jpeg_huff_decode() */ \
+ /* Don't use GET_BITS() here because we don't want to modify bits_left */ \
+ s = (get_buffer >> bits_left) & ((1 << (nb)) - 1); \
+ while (s > htbl->maxcode[nb]) { \
+ s <<= 1; \
+ s |= GET_BITS(1); \
+ nb++; \
+ } \
+ s = htbl->pub->huffval[ (int) (s + htbl->valoffset[nb]) & 0xFF ]; \
+ }
+
/* Out-of-line case for Huffman code fetching */
EXTERN(int) jpeg_huff_decode
JPP((bitread_working_state * state, register bit_buf_type get_buffer,