Some cleanup in VP8LCreateHuffmanTree() (and related functions

CompareHuffmanTrees() and SetBitDepths()):
- Move 'tree_size' initialization and malloc for 'tree + tree_pool'
  outside the loop.
- Some renames/tweaks for readability.

Change-Id: I5cb3cc942afac6e9f51a0b97c57ee897677a48a2
This commit is contained in:
Urvang Joshi
2012-05-09 14:22:43 +05:30
parent 861a5b7bc9
commit 2c140e113c
2 changed files with 72 additions and 77 deletions

View File

@ -22,17 +22,14 @@ extern "C" {
// This function will create a Huffman tree.
//
// The (data,length) contains the population counts.
// The tree_limit is the maximum bit depth of the Huffman codes.
//
// The depth contains the tree, i.e., how many bits are used for
// the symbol.
//
// 'histogram' contains the population counts.
// 'tree_depth_limit' is the maximum bit depth of the Huffman codes.
// The created tree is returned as 'bit_depths', which stores how many bits are
// used for each symbol.
// See http://en.wikipedia.org/wiki/Huffman_coding
//
// Returns 0 when an error has occured.
int VP8LCreateHuffmanTree(const int* data, const int length,
const int tree_limit, uint8_t* depth);
// Returns 0 on memory error.
int VP8LCreateHuffmanTree(const int* const histogram, int histogram_size,
int tree_depth_limit, uint8_t* const bit_depths);
// Write a huffman tree from bit depths. The generated Huffman tree is
// compressed once more using a Huffman tree.