Path: blob/master/thirdparty/libjpeg-turbo/src/jchuff.h
9904 views
/*1* jchuff.h2*3* This file was part of the Independent JPEG Group's software:4* Copyright (C) 1991-1997, Thomas G. Lane.5* libjpeg-turbo Modifications:6* Copyright (C) 2022, D. R. Commander.7* For conditions of distribution and use, see the accompanying README.ijg8* file.9*10* This file contains declarations for Huffman entropy encoding routines11* that are shared between the sequential encoder (jchuff.c) and the12* progressive encoder (jcphuff.c). No other modules need to see these.13*/1415/* The legal range of a DCT coefficient is16* -1024 .. +1023 for 8-bit data;17* -16384 .. +16383 for 12-bit data.18* Hence the magnitude should always fit in 10 or 14 bits respectively.19*/2021/* The progressive Huffman encoder uses an unsigned 16-bit data type to store22* absolute values of coefficients, because it is possible to inject a23* coefficient value of -32768 into the encoder by attempting to transform a24* malformed 12-bit JPEG image, and the absolute value of -32768 would overflow25* a signed 16-bit integer.26*/27typedef unsigned short UJCOEF;2829/* Derived data constructed for each Huffman table */3031typedef struct {32unsigned int ehufco[256]; /* code for each symbol */33char ehufsi[256]; /* length of code for each symbol */34/* If no code has been allocated for a symbol S, ehufsi[S] contains 0 */35} c_derived_tbl;3637/* Expand a Huffman table definition into the derived format */38EXTERN(void) jpeg_make_c_derived_tbl(j_compress_ptr cinfo, boolean isDC,39int tblno, c_derived_tbl **pdtbl);4041/* Generate an optimal table definition given the specified counts */42EXTERN(void) jpeg_gen_optimal_table(j_compress_ptr cinfo, JHUFF_TBL *htbl,43long freq[]);444546