private void assignHuffmanCodeSymbols ( ) { final int [ ] [ ] huffmanMergedCodeSymbols = this . huffmanMergedCodeSymbols ; final int [ ] [ ] huffmanCodeLengths = this . huffmanCodeLengths ; final int mtfAlphabetSize = this . mtfAlphabetSize ; final int totalTables = huffmanCodeLengths . length ; for ( int i = 0 ; i < totalTables ; i ++ ) { final int [ ] tableLengths = huffmanCodeLengths [ i ] ; int minimumLength = 32 ; int maximumLength = 0 ; for ( int j = 0 ; j < mtfAlphabetSize ; j ++ ) { final int length = tableLengths [ j ] ; if ( length > maximumLength ) { maximumLength = length ; } if ( length < minimumLength ) { minimumLength = length ; } } int code = 0 ; for ( int j = minimumLength ; j <= maximumLength ; j ++ ) { for ( int k = 0 ; k < mtfAlphabetSize ; k ++ ) { if ( ( huffmanCodeLengths [ i ] [ k ] & 0xff ) == j ) { huffmanMergedCodeSymbols [ i ] [ k ] = ( j << 24 ) | code ; code ++ ; } } code <<= 1 ; } } }
Assigns Canonical Huffman codes based on the calculated lengths .