background image
ISO/IEC 10918-1 : 1993(E)
Annex C
Huffman table specification
(This annex forms an integral part of this Recommendation | International Standard)
A Huffman coding procedure may be used for entropy coding in any of the coding processes. Coding models for
Huffman encoding are defined in Annexes F, G, and H. In this Annex, the Huffman table specification is defined.
Huffman tables are specified in terms of a 16-byte list (BITS) giving the number of codes for each code length from
1 to 16. This is followed by a list of the 8-bit symbol values (HUFFVAL), each of which is assigned a Huffman code. The
symbol values are placed in the list in order of increasing code length. Code lengths greater than 16 bits are not allowed.
In addition, the codes shall be generated such that the all-1-bits code word of any length is reserved as a prefix for longer
code words.
NOTE The order of the symbol values within HUFFVAL is determined only by code length. Within a given code length
the ordering of the symbol values is arbitrary.
This annex specifies the procedure by which the Huffman tables (of Huffman code words and their corresponding 8-bit
symbol values) are derived from the two lists (BITS and HUFFVAL) in the interchange format. However, the way in
which these lists are generated is not specified. The lists should be generated in a manner which is consistent with the
rules for Huffman coding, and it shall observe the constraints discussed in the previous paragraph. Annex K contains an
example of a procedure for generating lists of Huffman code lengths and values which are in accord with these rules.
NOTE There is no requirement in this Specification that any encoder or decoder shall implement the procedures in
precisely the manner specified by the flow charts in this annex. It is necessary only that an encoder or decoder implement the function
specified in this annex. The sole criterion for an encoder or decoder to be considered in compliance with this Specification is that it
satisfy the requirements given in clause 6 (for encoders) or clause 7 (for decoders), as determined by the compliance tests specified in
Part 2.
C.1
Marker segments for Huffman table specification
The DHT marker identifies the start of Huffman table definitions within the compressed image data. B.2.4.2 specifies the
syntax for Huffman table specification.
C.2
Conversion of Huffman table specifications to tables of codes and code lengths
Conversion of Huffman table specifications to tables of codes and code lengths uses three procedures. The first procedure
(Figure C.1) generates a table of Huffman code sizes. The second procedure (Figure C.2) generates the Huffman codes
from the table built in Figure C.1. The third procedure (Figure C.3) generates the Huffman codes in symbol value order.
Given a list BITS (1 to 16) containing the number of codes of each size, and a list HUFFVAL containing the symbol
values to be associated with those codes as described above, two tables are generated. The HUFFSIZE table contains a list
of code lengths; the HUFFCODE table contains the Huffman codes corresponding to those lengths.
Note that the variable LASTK is set to the index of the last entry in the table.
50
CCITT Rec. T.81 (1992 E)
[1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16] [17] [18] [19] [20] [21] [22] [23] [24] [25] [26] [27] [28] [29] [30] [31] [32] [33] [34] [35] [36] [37] [38] [39] [40] [41] [42] [43] [44] [45] [46] [47] [48] [49] [50] [51] [52] [53] [54] [55] [56] [57] [58] [59] [60] [61] [62] [63] [64] [65] [66] [67] [68] [69] [70] [71] [72] [73] [74] [75] [76] [77] [78] [79] [80] [81] [82] [83] [84] [85] [86] [87] [88] [89] [90] [91] [92] [93] [94] [95] [96] [97] [98] [99] [100] [101] [102] [103] [104] [105] [106] [107] [108] [109] [110] [111] [112] [113] [114] [115] [116] [117] [118] [119] [120] [121] [122] [123] [124] [125] [126] [127] [128] [129] [130] [131] [132] [133] [134] [135] [136] [137] [138] [139] [140] [141] [142] [143] [144] [145] [146] [147] [148] [149] [150] [151] [152] [153] [154] [155] [156] [157] [158] [159] [160] [161] [162] [163] [164] [165] [166] [167] [168] [169] [170] [171] [172] [173] [174] [175] [176] [177] [178] [179] [180] [181] [182] [183] [184] [185] [186]