private static int compressionLevel ( int blockSize ) { if ( blockSize < MIN_BLOCK_SIZE || blockSize > MAX_BLOCK_SIZE ) { throw new IllegalArgumentException ( String . format ( "blockSize: %d (expected: %d-%d)" , blockSize , MIN_BLOCK_SIZE , MAX_BLOCK_SIZE ) ) ; } int compressionLevel = 32 - Integer . numberOfLeadingZeros ( blockSize - 1 ) ; // ceil of log2 compressionLevel = Math . max ( 0 , compressionLevel - COMPRESSION_LEVEL_BASE ) ; return compressionLevel ; }
Calculates compression level on the basis of block size .