/*
* jstdhuff . c
*
* This file was part of the Independent JPEG Group ' s software :
* Copyright ( C ) 1991 - 1998 , Thomas G . Lane .
* libjpeg - turbo Modifications :
* Copyright ( C ) 2013 , 2022 , 2024 , D . R . Commander .
* For conditions of distribution and use , see the accompanying README . ijg
* file .
*
* This file contains routines to set the default Huffman tables , if they are
* not already set .
*/
/*
* Huffman table setup routines
*/
LOCAL(void )
add_huff_table(j_common_ptr cinfo, JHUFF_TBL **htblptr, const UINT8 *bits,
const UINT8 *val)
/* Define a Huffman table */
{
int nsymbols, len;
if (*htblptr == NULL)
*htblptr = jpeg_alloc_huff_table(cinfo);
else if (cinfo->is_decompressor)
return ;
/* Copy the number-of-symbols-of-each-code-length counts */
memcpy((*htblptr)->bits, bits, sizeof ((*htblptr)->bits));
/* Validate the counts. We do this here mainly so we can copy the right
* number of symbols from the val [ ] array , without risking marching off
* the end of memory . jchuff . c will do a more thorough test later .
*/
nsymbols = 0 ;
for (len = 1 ; len <= 16 ; len++)
nsymbols += bits[len];
if (nsymbols < 1 || nsymbols > 256 )
ERREXIT(cinfo, JERR_BAD_HUFF_TABLE);
memcpy((*htblptr)->huffval, val, nsymbols * sizeof (UINT8));
memset(&((*htblptr)->huffval[nsymbols]), 0 ,
(256 - nsymbols) * sizeof (UINT8));
/* Initialize sent_table FALSE so table will be written to JPEG file. */
(*htblptr)->sent_table = FALSE ;
}
LOCAL(void )
std_huff_tables(j_common_ptr cinfo)
/* Set up the standard Huffman tables (cf. JPEG standard section K.3) */
/* IMPORTANT: these are only valid for 8-bit data precision! */
{
JHUFF_TBL **dc_huff_tbl_ptrs, **ac_huff_tbl_ptrs;
static const UINT8 bits_dc_luminance[17 ] = {
/* 0-base */ 0, 0, 1, 5, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0
};
static const UINT8 val_dc_luminance[] = {
0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11
};
static const UINT8 bits_dc_chrominance[17 ] = {
/* 0-base */ 0, 0, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0
};
static const UINT8 val_dc_chrominance[] = {
0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11
};
static const UINT8 bits_ac_luminance[17 ] = {
/* 0-base */ 0, 0, 2, 1, 3, 3, 2, 4, 3, 5, 5, 4, 4, 0, 0, 1, 0x7d
};
static const UINT8 val_ac_luminance[] = {
0 x01, 0 x02, 0 x03, 0 x00, 0 x04, 0 x11, 0 x05, 0 x12,
0 x21, 0 x31, 0 x41, 0 x06, 0 x13, 0 x51, 0 x61, 0 x07,
0 x22, 0 x71, 0 x14, 0 x32, 0 x81, 0 x91, 0 xa1, 0 x08,
0 x23, 0 x42, 0 xb1, 0 xc1, 0 x15, 0 x52, 0 xd1, 0 xf0,
0 x24, 0 x33, 0 x62, 0 x72, 0 x82, 0 x09, 0 x0a, 0 x16,
0 x17, 0 x18, 0 x19, 0 x1a, 0 x25, 0 x26, 0 x27, 0 x28,
0 x29, 0 x2a, 0 x34, 0 x35, 0 x36, 0 x37, 0 x38, 0 x39,
0 x3a, 0 x43, 0 x44, 0 x45, 0 x46, 0 x47, 0 x48, 0 x49,
0 x4a, 0 x53, 0 x54, 0 x55, 0 x56, 0 x57, 0 x58, 0 x59,
0 x5a, 0 x63, 0 x64, 0 x65, 0 x66, 0 x67, 0 x68, 0 x69,
0 x6a, 0 x73, 0 x74, 0 x75, 0 x76, 0 x77, 0 x78, 0 x79,
0 x7a, 0 x83, 0 x84, 0 x85, 0 x86, 0 x87, 0 x88, 0 x89,
0 x8a, 0 x92, 0 x93, 0 x94, 0 x95, 0 x96, 0 x97, 0 x98,
0 x99, 0 x9a, 0 xa2, 0 xa3, 0 xa4, 0 xa5, 0 xa6, 0 xa7,
0 xa8, 0 xa9, 0 xaa, 0 xb2, 0 xb3, 0 xb4, 0 xb5, 0 xb6,
0 xb7, 0 xb8, 0 xb9, 0 xba, 0 xc2, 0 xc3, 0 xc4, 0 xc5,
0 xc6, 0 xc7, 0 xc8, 0 xc9, 0 xca, 0 xd2, 0 xd3, 0 xd4,
0 xd5, 0 xd6, 0 xd7, 0 xd8, 0 xd9, 0 xda, 0 xe1, 0 xe2,
0 xe3, 0 xe4, 0 xe5, 0 xe6, 0 xe7, 0 xe8, 0 xe9, 0 xea,
0 xf1, 0 xf2, 0 xf3, 0 xf4, 0 xf5, 0 xf6, 0 xf7, 0 xf8,
0 xf9, 0 xfa
};
static const UINT8 bits_ac_chrominance[17 ] = {
/* 0-base */ 0, 0, 2, 1, 2, 4, 4, 3, 4, 7, 5, 4, 4, 0, 1, 2, 0x77
};
static const UINT8 val_ac_chrominance[] = {
0 x00, 0 x01, 0 x02, 0 x03, 0 x11, 0 x04, 0 x05, 0 x21,
0 x31, 0 x06, 0 x12, 0 x41, 0 x51, 0 x07, 0 x61, 0 x71,
0 x13, 0 x22, 0 x32, 0 x81, 0 x08, 0 x14, 0 x42, 0 x91,
0 xa1, 0 xb1, 0 xc1, 0 x09, 0 x23, 0 x33, 0 x52, 0 xf0,
0 x15, 0 x62, 0 x72, 0 xd1, 0 x0a, 0 x16, 0 x24, 0 x34,
0 xe1, 0 x25, 0 xf1, 0 x17, 0 x18, 0 x19, 0 x1a, 0 x26,
0 x27, 0 x28, 0 x29, 0 x2a, 0 x35, 0 x36, 0 x37, 0 x38,
0 x39, 0 x3a, 0 x43, 0 x44, 0 x45, 0 x46, 0 x47, 0 x48,
0 x49, 0 x4a, 0 x53, 0 x54, 0 x55, 0 x56, 0 x57, 0 x58,
0 x59, 0 x5a, 0 x63, 0 x64, 0 x65, 0 x66, 0 x67, 0 x68,
0 x69, 0 x6a, 0 x73, 0 x74, 0 x75, 0 x76, 0 x77, 0 x78,
0 x79, 0 x7a, 0 x82, 0 x83, 0 x84, 0 x85, 0 x86, 0 x87,
0 x88, 0 x89, 0 x8a, 0 x92, 0 x93, 0 x94, 0 x95, 0 x96,
0 x97, 0 x98, 0 x99, 0 x9a, 0 xa2, 0 xa3, 0 xa4, 0 xa5,
0 xa6, 0 xa7, 0 xa8, 0 xa9, 0 xaa, 0 xb2, 0 xb3, 0 xb4,
0 xb5, 0 xb6, 0 xb7, 0 xb8, 0 xb9, 0 xba, 0 xc2, 0 xc3,
0 xc4, 0 xc5, 0 xc6, 0 xc7, 0 xc8, 0 xc9, 0 xca, 0 xd2,
0 xd3, 0 xd4, 0 xd5, 0 xd6, 0 xd7, 0 xd8, 0 xd9, 0 xda,
0 xe2, 0 xe3, 0 xe4, 0 xe5, 0 xe6, 0 xe7, 0 xe8, 0 xe9,
0 xea, 0 xf2, 0 xf3, 0 xf4, 0 xf5, 0 xf6, 0 xf7, 0 xf8,
0 xf9, 0 xfa
};
if (cinfo->is_decompressor) {
dc_huff_tbl_ptrs = ((j_decompress_ptr)cinfo)->dc_huff_tbl_ptrs;
ac_huff_tbl_ptrs = ((j_decompress_ptr)cinfo)->ac_huff_tbl_ptrs;
} else {
dc_huff_tbl_ptrs = ((j_compress_ptr)cinfo)->dc_huff_tbl_ptrs;
ac_huff_tbl_ptrs = ((j_compress_ptr)cinfo)->ac_huff_tbl_ptrs;
}
add_huff_table(cinfo, &dc_huff_tbl_ptrs[0 ], bits_dc_luminance,
val_dc_luminance);
add_huff_table(cinfo, &ac_huff_tbl_ptrs[0 ], bits_ac_luminance,
val_ac_luminance);
add_huff_table(cinfo, &dc_huff_tbl_ptrs[1 ], bits_dc_chrominance,
val_dc_chrominance);
add_huff_table(cinfo, &ac_huff_tbl_ptrs[1 ], bits_ac_chrominance,
val_ac_chrominance);
}
Messung V0.5 in Prozent C=84 H=88 G=85