You are on page 1of 7

See discussions, stats, and author profiles for this publication at: https://www.researchgate.

net/publication/220804798

An Adaptive Huffman Decoding Algorithm for MP3 Decoder

Conference Paper · January 2010


DOI: 10.1109/DELTA.2010.22 · Source: DBLP

CITATIONS READS

2 1,392

3 authors, including:

Hoang-Anh Pham
Ho Chi Minh City University of Technology (HCMUT)
54 PUBLICATIONS   211 CITATIONS   

SEE PROFILE

Some of the authors of this publication are also working on these related projects:

research on enterprise software and processes View project

To-KHMT-2020-03 View project

All content following this page was uploaded by Hoang-Anh Pham on 23 November 2018.

The user has requested enhancement of the downloaded file.


Proceedings
Fifth IEEE International Symposium on
Electronic Design, Test and Applications

DELTA 2010

13-15 January 2010


Ho Chi Minh City, Vietnam

Sponsored by
Published by the IEEE Computer Society
10662 Los Vaqueros Circle IEEE Computer Society Test Technology Technical Council (TTTC)
P.O. Box 3014 IEEE Vietnam Section
Los Alamitos, CA 90720-1314 Ho Chi Minh City University of Technology

IEEE Computer Society Order Number P3978


ISBN 978-0-7695-3978-2
Library of Congress Number 2009942538
Fifth IEEE International Symposium on Electronic Design, Test and Applications

BMS Part Number CFP10286-PRT


2010 Fifth IEEE International Symposium on Electronic Design, Test & Applications

An Adaptive Huffman Decoding Algorithm for MP3 Decoder

Hoang-Anh Pham, Van-Hieu Bui, and Anh-Vu Dinh-Duc


Faculty of Computer Science and Engineering, HoChiMinh City University of Technology, Vietnam
{anhph, bvhieu, anhvu}@cse.hcmut.edu.vn

Abstract—This paper proposes a novel array data structure to adaptation still keeps the key advantages of the SGHC
represent Huffman code table and an adaptive algorithm for approach which provides memory efficient and fast Huffman
Huffman decoding based on Single-side Growing Huffman decoding. The rest of this paper is organized in the following
Coding approach which provides a memory efficient and high- manner. In Section II, a study on SGHC approach is briefly
speed decoding algorithm. The search time of the proposed presented. The drawback of this approach is mentioned and
algorithm for finding a symbol is ªCL 4 º where CL is the code considered. Then, an adaptive algorithm on our novel data
length of the corresponding symbol. The implementation of the structure including its implementation is proposed in Section
proposed algorithm is applied for MP3 decoding and the III. Experiment on MP3 decoding is performed and the result
experiment result shows that our algorithm is applicable to all is presented and shown in Section IV. The last section
Huffman decoding applications. discusses conclusions.

Keywords—Huffman decoding, Huffman Code Table (HCT), TABLE I AN EXAMPLE OF HUFFMAN CODE TABLE (HCT)
Huffman Tree (HT), Single-side growing Huffman Tree (SGH-
Huffman Code Huffman Code
Tree), Single-side growing Huffman coding (SGHC) Symbol Symbol
Code Length Code Length
I. INTRODUCTION 0x00 011 3 0x0C 00101 5
Huffman coding is a method that compresses and 0x01 100 3 0x0D 000001 6
encodes a given set of data by using a variable-length code 0x02 101 3 0x0E 000010 6
table. The variable-length code table is derived in a particular 0x03 111 3 0x0F 0000110 7
way based on the estimated occurrence probability of each
0x04 0011 4 0x10 0000111 7
possible value of the source symbol [1].
0x05 0100 4 0x11 00000001 8
The key issues on Huffman coding implementation are
the representation of the Huffman code table (HCT) and the 0x06 0101 4 0x12 00000010 8
corresponding decoding algorithm. The conventional 0x07 1100 4 0x13 00000011 8
approach is to represent the HCT by Huffman tree (HT) and 0x08 1101 4 0x14 0000000000 10
apply the binary tree search schemes for decoding. However,
0x09 00010 5 0x15 0000000001 10
the tree data structure is not appropriate in real applications
due to memory requirement and decoding time. Figure 1 0x0A 00011 5 0x16 0000000010 10
shows the corresponding HT which represents for the HCT 0x0B 00100 5 0x17 0000000010 10
in TABLE I.
Various implementation techniques for Huffman coding
have been studied and applied [1-7]. They optimize the HT
by representing HT as an array and provide an efficient
decoding algorithm in order to reduce the memory
requirement and the decoding time. Chung et al. proposed a
novel approach for memory efficiency [3]. The search time
for finding a symbol is O(d) where d denotes the depth of
HT. Hashemian et al. proposed an array data structure to
represent HT and provide an efficient decoding algorithm
[2][4]. Wang et al. proposed a new data structure on which
the decoding time is O(n) where n is the number of source
symbols [5]. Recently, Gutemberg at al. proposed an
improvement based on the approach, proposed by Lee et al.
([6]), for fast decoding mechanism [7].
In this paper, we also propose an array data structure to
Figure 1 Huffman tree (HT) corresponding to HCT in TABLE I
represent HCT and corresponding decoding algorithm. The
proposed data structure overcomes the draw-back in the
SGHC approach proposed by Hashemian [2]. This

978-0-7695-3978-2/10 $26.00 © 2010 IEEE 153


DOI 10.1109/DELTA.2010.22
II. STUDY ON SINGLE-SIDE GROWING HUFFMAN CODING applications since this approach provides memory efficiency
and fast decoding.
A. Single-side Growing Huffman Coding Approach
This approach has been developed on a special HT,
called single-side growing Huffman Tree (SGH-Tree),
whose growth is directed toward one side of the tree. The
SGH-Tree is represented as a corresponding HCT called
single-side growing Huffman Table (SGHT) which has been
constructed in two steps by applying two algorithms in [2].
For example, TABLE II shows the SGHT that is equivalent
to the HCT shown in TABLE I. Figure 2 Block diagram of Huffman coding application

TABLE II SGHT REPRESENTATION OF THE HCT IN TABLE I However, the encoding phase of these applications has
been already developed. That means the HCT and encoded
Huffman Code Huffman Code data have been already provided. So only the decoding phase
Symbol Symbol
Code Length Code Length is needed. The drawback is that the HCT may not meet the
0x00 000 3 0x0C 11101 5 properties of an SGHT so the SGHC approach can not be
applied.
0x01 001 3 0x0D 111100 6
Based on the SGHC approach, we propose a new data
0x02 010 3 0x0E 111101 6 structure and improve the corresponding decoding algorithm
0x03 011 3 0x0F 1111100 7 that is applicable to general applications. The details are
0x04 1000 4 0x10 1111101 7 presented in the next section.
0x05 1001 4 0x11 11111100 8 III. ADAPTIVE ALGORITHM AND ITS IMPLEMENTATION
0x06 1010 4 0x12 11111101 8
0x07 1011 4 0x13 11111110 8 A. Data Structure
0x08 1100 4 0x14 1111111100 10 A given HT is partitioned into smaller sub-trees called
0x09 11010 5 0x15 1111111101 10
clusters. The cut-line is at the 4th level and proceeds
recursively for the new sub-trees until their heights are less
0x0A 11011 5 0x16 1111111110 10 than or equal to 4. The above selection is appropriate to our
0x0B 11100 5 0x17 1111111111 10 data structures and it is an average value of MME (Minimum
Memory Efficiency) factor following the SGHC approach
The essential idea of the SGHC approach is to increase [2]. The Figure 3 shows the clusters obtained by partitioning
the memory efficiency (reduce memory requirement) by the HT shown in Figure 1. Each cluster is represented by a
partitioning the SGH-Tree into smaller sub-trees called root node numbered 0, 1, 2 … as identification (ID). In each
clusters. Further, clustering also helps to reduce the search cluster, the leaf node can denote a symbol or a root node of
time for finding a symbol. other cluster.
However, there is a drawback in this approach for
applications in use. It will be mentioned and discussed in the
following.
B. Issues
0 shows the basic block diagram of an application using
Huffman coding. The two major phases are encoding and
decoding. The encoding phase is to compress and represent
the original data in Huffman code (encoded data) and HCT
which saves the relationship between the original data and
Huffman code. The encoded data and the HCT are used to
reconstruct the original data in the decoding phase. The
performance of the decoding phase is considered for whole
applications.
Although there are many techniques for compressing
data, Huffman coding has been widely used in many
multimedia applications such as MP3, JPEG, ACC, and
H.264. These applications are directed to the sharing
problems via internet and mobile devices which have limited
memory and require the real-time execution. Hence, it is
appropriate if the SGHC approach can be applied to these
Figure 3 The HT-clusters corresponding to the HT in Figure 1

154
A new tree called super-tree (ST) is constructed to the LUT and SYT corresponding with the HT clusters in
represent the connection of the above clusters via the root Figure 3. These tables are numbered same as the cluster ID
nodes. The corresponding ST with the clusters in Figure 3 is in ST shown in Figure 4 respectively. In LUT, the value of
shown in Figure 4. each entry is an unsigned integer corresponding with its
structure.

TABLE IV LUTS AND SYTS OF HT-CLUSTERS IN FIGURE 3

Table ID = 0
Look-up Table Symbol Table
Entry
Index Index Symbol
Figure 4 The Super-Tree corresponding to the HT-clusters in Figure 3 Structure Value
0000 1 0000001 129 0000 0x04
As the conventional approaches, the clusters obtained
0001 1 0000010 130 0001 0x05
from the previous step will be represented in an array data
structures called look-up tables (LUT). Each cluster is 0010 1 0000011 131 0010 0x06
represented in an individual LUT and named as an ID 0011 0 0 0000 11 3 0011 0x00
number in order to identify the LUTs. In most of 0100 0 0 0001 11 7 0100 0x01
conventional approaches, the LUT saves all nodes of the
0101 0 0 0010 11 11 0101 0x02
corresponding HT including intermediate nodes and leaf
nodes. In our approach, only leaf nodes are stored in the 0110 0 0 0011 10 14 0110 0x07
LUT. 0111 0 0 0011 10 14 0111 0x08
In a cluster, a leaf node can be a symbol node or a root 1000 0 0 0100 10 18 1000 0x03
node of other cluster called link node. So, in the
1001 0 0 0100 10 18
corresponding LUT, an entry can be a symbol entry or a link
entry representing the symbol node or link node respectively. 1010 0 0 0101 10 22
A new data structure for an entry of the LUT is proposed 1011 0 0 0101 10 22
shown in Figure 5. Symbol entry or link entry is identified by 1100 0 0 0110 11 27
the Most Significant Bit (MSB).
1101 0 0 0111 11 31
1110 0 0 1000 10 38
1111 0 0 1000 10 38
Table ID = 1
Look-up Table Symbol Table
Entry
Index Index Symbol
Figure 5 Entry Format of the LUT Structure Value
0000 1 0000100 132 0000 0x11
For the symbol entry, the Symbol Index field is used to
identify the symbol value corresponding to the symbol entry. 0001 0 0 0000 11 3 0001 0x12
The CL (Code Length) field indicates the path length from 0010 0 0 0001 11 7 0010 0x13
the root node to the symbol node in a cluster. The value of 0011 0 0 0010 11 11 0011 0x0D
the CL field is defined in TABLE III. 0100 0 0 0011 01 13 0100 0x0E
For the link entry, the Link Table ID field is used to
0101 0 0 0011 01 13 0101 0x0F
identify the LUT of the corresponding cluster.
0110 0 0 0011 01 13 0110 0x10
TABLE III DEFINITION OF CL FIELD 0111 0 0 0011 01 13
CL = Code Length 1000 0 0 0100 01 17

Code Value Code Value 1001 0 0 0100 01 17

00 1 10 3 1010 0 0 0100 01 17

01 2 11 4 1011 0 0 0100 01 17
1100 0 0 0101 10 22
There are two tables used to represent a cluster. The first 1101 0 0 0101 10 22
one is the LUT described above. The rest one is called 1110 0 0 0110 10 26
Symbol Table (SYT) which saves the symbol values of the 1111 0 0 0110 10 26
symbol entries in the corresponding LUT. TABLE IV shows

155
Table ID = 2 CL of symbol node “0x15” is 10 and it belongs to the 4th
Look-up Table Symbol Table cluster whose height is ª10 4 º = 3 in the corresponding ST.
Entry Hence, the search time for finding a symbol is ªCL 4 º where
Index Index Symbol
Structure Value CL is the code length of the corresponding symbol.
0 0 0 0000 00 0 0000 0x09
1 0 0 0001 00 4 0001 0x0A
Table ID = 3
Look-up Table Symbol Table
Entry
Index Index Symbol
Structure Value
0 0 0 0000 00 0 0000 0x0B
1 0 0 0001 00 4 0001 0x0C
Table ID = 4
Look-up Table Symbol Table
Entry
Index Index Symbol
Structure Value
00 0 0 0000 01 1 0000 0x14
01 0 0 0001 01 5 0001 0x15
10 0 0 0010 01 9 0010 0x16
11 0 0 0011 01 13 0011 0x17 Figure 6 Flow chart of decoding algorithm

TABLE V CLUSTER HEIGHT TABLE The following example illustrates the steps of the above
algorithm. The encoded data represented in bit-stream
Cluster ID Height “000000001000001101101” and the LUTs, SYTs, CHT are
0 4 given in TABLE IV and TABLE V.
1 4 First, first four bits are loaded “0000” and TableId is 0.
The entry at index “0000” of the 0th LUT is a link entry. The
2 1
corresponding Link Table ID field is “0000001” which
3 1 identifies for the 1st LUT and SYT. The bit-stream is updated
4 2 as “0000100000011101”. The height of the 1st cluster is 4.
Then, four new bits are loaded “0000”. The entry at index
B. Decoding Algorithm “0000” of the 1st LUT is a link entry. The corresponding Link
The LUTs, SYTs, CHT obtained in the previous step and Table ID field is “0000100” which identifies for the 4th LUT
a given encoded data in bit-stream are inputs for the and SYT. The bit-stream is updated as “100000011101”. The
decoding phases. The decoding procedure is described by the height of the 4th cluster is 2. Then, two new bits are loaded
adaptive algorithm below. Figure 6 shows the flow chart of “10”. The entry at index “10” of the 4th LUT is now a
the proposed decoding algorithm. symbol entry. The corresponding Symbol Index field is
The essential idea of the decoding algorithm proposed “0010” which is used to access the 4th SYT. The symbol
above for finding a symbol is to traverse the cluster nodes in value “0x16” is identified. The process is reset to find new
the corresponding Super-Tree (ST). The numbers of bits symbol. The remaining bit-stream is “000001101101”.
loaded at a time for searching are equal to the size of the Second, first four bits are loaded “0000” and TableId is
cluster which is being traversed. A symbol is decoded until reset to 0. The entry at index “0000” of the 0th LUT is a link
the cluster, which the corresponding symbol belongs to, is entry. The corresponding Link Table ID field is “0000001”
traversed. So, the decoding time for a symbol is equal to the which identifies for the 1st LUT and SYT. The bit-stream is
height of the corresponding cluster in the ST if the height of updated as “1101101”. The height of the 1st cluster is 4.
the root node in the ST is numbered as one. Then, four new bits are loaded “1101”. The entry at index
The code length of a symbol in original HT is the path “1101” of the 1st LUT is a symbol entry. The corresponding
length from the root node to the corresponding symbol node. Symbol Index field is “0101” which is used to access the 1st
As the partitioning process and the ST construction which SYT. The symbol value “0x0F” is identified. The
are described in the previous section, for a node with CL in corresponding CL field is “10” which indicates that only first
the original HT, the height of the corresponding cluster in the 3-bit in 4-bit loaded is decoded. So the remaining bit-stream
ST, which the node belongs to, is ªCL 4 º . For example, the is “1101”.

156
V. CONCLUSION
Similarly, first four bits are loaded “1101” and TableId is In this paper, we propose a new array data structure to
reset to 0. The entry at index “1101” of the 0th LUT is a represent the Huffman Tree. Based on the Single-side
symbol entry. The corresponding Symbol Index field is growing Huffman coding approach, we improve and propose
“0111” which is used to access the 0th SYT. The symbol an adaptive decoding algorithm for the corresponding data
value “0x08” is identified. The corresponding CL field is structures. The proposed algorithm provides a memory
“11” which indicates a codeword 4-bit decoded. The bit- efficient and high-speed Huffman decoding. The search time
stream is empty so the decoding process is complete.
to identify a symbol is ªCL 4 º . An experiment has been
Hence, the bit-stream “000000001000001101101”
encodes for three symbols: “0x16”, “0x0F”, “0x08”. performed on an MP3 decoding application. This result also
shows that the proposed algorithm is applicable to all
IV. EXPERIMENTS Huffman decoding applications such as JPEG, ACC, and
The implementation of the proposed algorithm is applied H.264.
to an MP3 decoding application. There are 17 various
Huffman code tables [8] used for MP3. These HCT do not REFERENCES
meet the properties of a SGHT so it is not possible to apply
[1] A. Huffman, “A method for the construction of minimum redundancy
the original SGHC approach. However, it is successful to codes”, Proc. of IRE, Vol. 40, pp. 1098–1101, Sep 1952.
apply our approach.
[2] R. Hashemian, “Memory efficient and high-speed search Huffman
A converter has been developed to transform the MP3 coding”, Proc. of IEEE, Vol. 43, No. 10, pp. 2576–2581, Oct 1995.
Huffman code table (MP3-HCT) into the LUT and the SYT [3] K. L. Chung and Y. K. Lin, “A novel memory-efficient Huffman
whole structures are proposed in the previous section. Since decoding algorithm and its implementation,” Signal Processing, vol.
the MP3-HCTs are standardized and available, the 62, pp. 207–213, 1997.
converting process is considered as a preprocessing step. [4] R. Hashemian, “Condensed table of Huffman coding, a New
approach to efficient decoding”, Proc. of IEEE, vol. 52, No. 1, Jan
Then, the proposed decoding algorithm is performed. 2004.
The overall performance depends on both the algorithm’s [5] P.C. Wang, Y.R. Yang, C.L. Lee and H.Y. Chang, “A memory-
complexity and the algorithm’s implementation for a real efficient Hufman decoding algorithm”, Proc. of the 19th International
application. So it is not significant to provide an overall Conference on Advanced Information Networking and Applications
performance comparison with some other approaches. In this (AINA’05), vol. 2, pp 475-479, Mar 2005.
paper, we only discuss the algorithm’s performance [6] J.S. Lee, J.H. Jeong, T.G. Chang. “An efficient method of Huffman
decoding for MPEG-2 ACC and its performance analysis”, IEEE
theoretically. In that way, the search time for finding a Trans. on Speed and Audio Processing, vol. 12, pp. 1206-1209, 2005.
symbol in our approach is identical to the original SGHC [7] G.S. Gutemberg, M.A.M Lima, W.O.G. Filho, A. Perkusick, M.R.A.
approach for a same MME factor [2]. The key advantage of Morais, A.M.N Lima, “A fast and memory efficient Huffman
our approach is applicable to every Huffman Code Table but decoding method for the MPEG-4 ACC standard”, Proc. of ICCE
the original SGHC approach is not. 2008, pp. 1-2, Jan 2008.
[8] ISO/IEC 11172-3 “Coding of moving pictures and associated audio
for digital storagemedia at up to about 1,5 Mbit/s – Part 3”, 1993.

157

View publication stats

You might also like