go2hx

manual

github

Module: stdgo.compress.bzip2

(view library index)

Overview

Package bzip2 implements bzip2 decompression.

Index

Constants

import stdgo.compress.bzip2.Bzip2
final _bzip2BlockMagic:stdgo.GoUInt64 = ((54156738319193i64 : stdgo.GoUInt64))
final _bzip2FileMagic:stdgo.GoUInt64 = ((16986i64 : stdgo.GoUInt64))

"BZ"

final _bzip2FinalMagic:stdgo.GoUInt64 = ((25779555029136i64 : stdgo.GoUInt64))
final _invalidNodeValue:stdgo.GoUInt64 = ((65535i64 : stdgo.GoUInt64))

invalidNodeValue is an invalid index which marks a leaf node in the tree.

Variables

import stdgo.compress.bzip2.Bzip2
var _:Bool
var _crctab:stdgo.GoArray<stdgo.GoUInt32>
var _digits:stdgo.Slice<stdgo.GoUInt8>
var _newton:stdgo.Slice<stdgo.GoUInt8>
var _random:stdgo.Slice<stdgo.GoUInt8>

Functions

import stdgo.compress.bzip2.Bzip2

function _benchmarkDecode

function _benchmarkDecode(_b:stdgo.Ref<stdgo.testing.B>, _compressed:stdgo.Slice<stdgo.GoByte>):Void

(view code)

function _buildHuffmanNode

function _buildHuffmanNode(_t:stdgo.Ref<stdgo.compress.bzip2.T_huffmanTree>, _codes:stdgo.Slice<stdgo.compress.bzip2.T_huffmanCode>, _level:stdgo.GoUInt32):{
	_1:stdgo.Error;
	_0:stdgo.GoUInt16;
}

buildHuffmanNode takes a slice of sorted huffmanCodes and builds a node in the Huffman tree at the given level. It returns the index of the newly constructed node.

(view code)

function _inverseBWT

function _inverseBWT(_tt:stdgo.Slice<stdgo.GoUInt32>, _origPtr:stdgo.GoUInt, _c:stdgo.Slice<stdgo.GoUInt>):stdgo.GoUInt32

inverseBWT implements the inverse Burrows-Wheeler transform as described in http://www.hpl.hp.com/techreports/Compaq-DEC/SRC-RR-124.pdf, section 4.2. In that document, origPtr is called “I” and c is the “C” array after the first pass over the data. It's an argument here because we merge the first pass with the Huffman decoding.

This also implements the “single array” method from the bzip2 source code which leaves the output, still shuffled, in the bottom 8 bits of tt with the index of the next byte in the top 24-bits. The index of the first byte is returned.

(view code)

function _mustDecodeHex

function _mustDecodeHex(_s:stdgo.GoString):stdgo.Slice<stdgo.GoByte>

(view code)

function _mustLoadFile

function _mustLoadFile(_f:stdgo.GoString):stdgo.Slice<stdgo.GoByte>

(view code)

function _newBitReader

function _newBitReader(_r:stdgo.io.Reader):stdgo.compress.bzip2.T_bitReader

newBitReader returns a new bitReader reading from r. If r is not already an io.ByteReader, it will be converted via a bufio.Reader.

(view code)

function _newHuffmanTree

function _newHuffmanTree(_lengths:stdgo.Slice<stdgo.GoUInt8>):{
	_1:stdgo.Error;
	_0:stdgo.compress.bzip2.T_huffmanTree;
}

newHuffmanTree builds a Huffman tree from a slice containing the code lengths of each symbol. The maximum code length is 32 bits.

(view code)

function _newMTFDecoder

function _newMTFDecoder(_symbols:stdgo.Slice<stdgo.GoByte>):stdgo.compress.bzip2.T_moveToFrontDecoder

newMTFDecoder creates a move-to-front decoder with an explicit initial list of symbols.

(view code)

function _newMTFDecoderWithRange

function _newMTFDecoderWithRange(_n:stdgo.GoInt):stdgo.compress.bzip2.T_moveToFrontDecoder

newMTFDecoderWithRange creates a move-to-front decoder with an initial symbol list of 0...n-1.

(view code)

function _trim

function _trim(_b:stdgo.Slice<stdgo.GoByte>):stdgo.GoString

(view code)

function _updateCRC

function _updateCRC(_val:stdgo.GoUInt32, _b:stdgo.Slice<stdgo.GoByte>):stdgo.GoUInt32

updateCRC updates the crc value to incorporate the data in b. The initial value is 0.

(view code)

function benchmarkDecodeDigits

function benchmarkDecodeDigits(_b:stdgo.Ref<stdgo.testing.B>):Void

(view code)

function benchmarkDecodeNewton

function benchmarkDecodeNewton(_b:stdgo.Ref<stdgo.testing.B>):Void

(view code)

function benchmarkDecodeRand

function benchmarkDecodeRand(_b:stdgo.Ref<stdgo.testing.B>):Void

(view code)

function newReader

function newReader(_r:stdgo.io.Reader):stdgo.io.Reader

NewReader returns an io.Reader which decompresses bzip2 data from r. If r does not also implement io.ByteReader, the decompressor may read more data than necessary from r.

(view code)

function testBitReader

function testBitReader(_t:stdgo.Ref<stdgo.testing.T_>):Void

(view code)

function testMTF

function testMTF(_t:stdgo.Ref<stdgo.testing.T_>):Void

(view code)

function testReader

function testReader(_t:stdgo.Ref<stdgo.testing.T_>):Void

(view code)

function testZeroRead

function testZeroRead(_t:stdgo.Ref<stdgo.testing.T_>):Void

(view code)

Typedefs

import stdgo.compress.bzip2.*

typedef StructuralError

typedef StructuralError = stdgo.GoString;

A StructuralError is returned when the bzip2 data is found to be syntactically invalid.

typedef T__struct_0

typedef T__struct_0 = {
	_output:stdgo.Slice<stdgo.GoUInt8>;
	_input:stdgo.Slice<stdgo.GoUInt8>;
	_fail:Bool;
	_desc:stdgo.GoString;
};

typedef T__struct_1

typedef T__struct_1 = {
	_value:stdgo.GoInt;
	_nbits:stdgo.GoUInt;
	_fail:Bool;
};

typedef T__struct_2

typedef T__struct_2 = {
	_sym:stdgo.GoUInt8;
	_idx:stdgo.GoInt;
};

typedef T_moveToFrontDecoder

typedef T_moveToFrontDecoder = stdgo.Slice<stdgo.GoUInt8>;

moveToFrontDecoder implements a move-to-front list. Such a list is an efficient way to transform a string with repeating elements into one with many small valued numbers, which is suitable for entropy encoding. It works by starting with an initial list of symbols and references symbols by their index into that list. When a symbol is referenced, it's moved to the front of the list. Thus, a repeated symbol ends up being encoded with many zeros, as the symbol will be at the front of the list after the first access.