HW5 Camera/HW5 Camera/stb_image.h
// build a table that decodes both magnitude and value of small ACs in
// one go.
build a table that decodes both magnitude and value of small ACs in
one go.
build a table that decodes both magnitude and value of small ACs in one go .
static void stbi__build_fast_ac(stbi__int16 *fast_ac, stbi__huffman *h)
{
	int i;
	for (i = 0; i < (1 << FAST_BITS); ++i) {
		stbi_uc fast = h->fast[i];
		fast_ac[i] = 0;
		if (fast < 255) {
			int rs = h->values[fast];
			int run = (rs >> 4) & 15;
			int magbits = rs & 15;
			int len = h->size[fast];
			if (magbits && len + magbits <= FAST_BITS) {
				int k = ((i << len) & ((1 << FAST_BITS) - 1)) >> (FAST_BITS - magbits);
				int m = 1 << (magbits - 1);
				if (k < m) k += (~0U << magbits) + 1;
				if (k >= -128 && k <= 127)
					fast_ac[i] = (stbi__int16)((k * 256) + (run * 16) + (len + magbits));
			}
		}
	}
}
static void stbi__build_fast_ac ( stbi__int16 * fast_ac , stbi__huffman * h ) { int i ; for ( i = 0 ; i < ( 1 << FAST_BITS ) ; ++ i ) { stbi_uc fast = h -> fast [ i ] ; fast_ac [ i ] = 0 ; if ( fast < 255 ) { int rs = h -> values [ fast ] ; int run = ( rs >> 4 ) & 15 ; int magbits = rs & 15 ; int len = h -> size [ fast ] ; if ( magbits && len + magbits <= FAST_BITS ) { int k = ( ( i << len ) & ( ( 1 << FAST_BITS ) - 1 ) ) >> ( FAST_BITS - magbits ) ; int m = 1 << ( magbits - 1 ) ; if ( k < m ) k += ( ~ 0U << magbits ) + 1 ; if ( k >= -128 && k <= 127 ) fast_ac [ i ] = ( stbi__int16 ) ( ( k * 256 ) + ( run * 16 ) + ( len + magbits ) ) ; } } } }
build a table that decodes both magnitude and value of small ACs in
one go.
build a table that decodes both magnitude and value of small ACs in one go .
// magnitude code followed by receive_extend code // if the result is small enough, we can fit it in fast_ac table