00001 /* 00002 * jchuff.h 00003 * 00004 * Copyright (C) 1991-1997, Thomas G. Lane. 00005 * This file is part of the Independent JPEG Group's software. 00006 * For conditions of distribution and use, see the accompanying README file. 00007 * 00008 * This file contains declarations for Huffman entropy encoding routines 00009 * that are shared between the sequential encoder (jchuff.c) and the 00010 * progressive encoder (jcphuff.c). No other modules need to see these. 00011 */ 00012 00013 /* The legal range of a DCT coefficient is 00014 * -1024 .. +1023 for 8-bit data; 00015 * -16384 .. +16383 for 12-bit data. 00016 * Hence the magnitude should always fit in 10 or 14 bits respectively. 00017 */ 00018 00019 #if BITS_IN_JSAMPLE == 8 00020 #define MAX_COEF_BITS 10 00021 #else 00022 #define MAX_COEF_BITS 14 00023 #endif 00024 00025 /* Derived data constructed for each Huffman table */ 00026 00027 typedef struct { 00028 unsigned int ehufco[256]; /* code for each symbol */ 00029 char ehufsi[256]; /* length of code for each symbol */ 00030 /* If no code has been allocated for a symbol S, ehufsi[S] contains 0 */ 00031 } c_derived_tbl; 00032 00033 /* Short forms of external names for systems with brain-damaged linkers. */ 00034 00035 #ifdef NEED_SHORT_EXTERNAL_NAMES 00036 #define jpeg_make_c_derived_tbl jMkCDerived 00037 #define jpeg_gen_optimal_table jGenOptTbl 00038 #endif /* NEED_SHORT_EXTERNAL_NAMES */ 00039 00040 /* Expand a Huffman table definition into the derived format */ 00041 EXTERN(void) jpeg_make_c_derived_tbl 00042 JPP((j_compress_ptr cinfo, boolean isDC, int tblno, 00043 c_derived_tbl ** pdtbl)); 00044 00045 /* Generate an optimal table definition given the specified counts */ 00046 EXTERN(void) jpeg_gen_optimal_table 00047 JPP((j_compress_ptr cinfo, JHUFF_TBL * htbl, long freq[]));