cosmetics: VP8LCreateHuffmanTree: fix indent

Change-Id: I025fada400366f8937208e1f9b8df483cd53a942
This commit is contained in:
James Zern 2012-05-09 12:11:22 -07:00
parent 89d803c423
commit 27541fbdc0

View File

@ -76,21 +76,20 @@ int VP8LCreateHuffmanTree(const int* const histogram, int histogram_size,
HuffmanTree* tree_pool; HuffmanTree* tree_pool;
HuffmanTree* tree; HuffmanTree* tree;
int tree_size_orig = 0; int tree_size_orig = 0;
int i; int i;
for (i = 0; i < histogram_size; ++i) { for (i = 0; i < histogram_size; ++i) {
if (histogram[i] != 0) { if (histogram[i] != 0) {
++tree_size_orig; ++tree_size_orig;
}
} }
// 3 * tree_size is enough to cover all the nodes representing a }
// population and all the inserted nodes combining two existing nodes. // 3 * tree_size is enough to cover all the nodes representing a
// population and all the inserted nodes combining two existing nodes.
// The tree pool needs 2 * (tree_size_orig - 1) entities, and the // The tree pool needs 2 * (tree_size_orig - 1) entities, and the
// tree needs exactly tree_size_orig entities. // tree needs exactly tree_size_orig entities.
tree = (HuffmanTree*)malloc(3 * tree_size_orig * sizeof(*tree)); tree = (HuffmanTree*)malloc(3 * tree_size_orig * sizeof(*tree));
if (tree == NULL) return 0; if (tree == NULL) return 0;
tree_pool = tree + tree_size_orig; tree_pool = tree + tree_size_orig;
// For block sizes with less than 64k symbols we never need to do a // For block sizes with less than 64k symbols we never need to do a
// second iteration of this loop. // second iteration of this loop.
// If we actually start running inside this loop a lot, we would perhaps // If we actually start running inside this loop a lot, we would perhaps
@ -98,26 +97,24 @@ int VP8LCreateHuffmanTree(const int* const histogram, int histogram_size,
assert(tree_size_orig <= (1 << (tree_depth_limit - 1))); assert(tree_size_orig <= (1 << (tree_depth_limit - 1)));
for (count_min = 1; ; count_min *= 2) { for (count_min = 1; ; count_min *= 2) {
int tree_size = tree_size_orig; int tree_size = tree_size_orig;
{ // We need to pack the Huffman tree in tree_depth_limit bits.
// We need to pack the Huffman tree in tree_depth_limit bits. // So, we try by faking histogram entries to be at least 'count_min'.
// So, we try by faking histogram entries to be at least 'count_min'. int idx = 0;
int idx = 0; int j;
int j; for (j = 0; j < histogram_size; ++j) {
for (j = 0; j < histogram_size; ++j) { if (histogram[j] != 0) {
if (histogram[j] != 0) { const int count =
const int count = (histogram[j] < count_min) ? count_min : histogram[j];
(histogram[j] < count_min) ? count_min : histogram[j]; tree[idx].total_count_ = count;
tree[idx].total_count_ = count; tree[idx].value_ = j;
tree[idx].value_ = j; tree[idx].pool_index_left_ = -1;
tree[idx].pool_index_left_ = -1; tree[idx].pool_index_right_ = -1;
tree[idx].pool_index_right_ = -1; ++idx;
++idx;
}
} }
} }
// Build the Huffman tree. // Build the Huffman tree.
qsort((void*)tree, tree_size, sizeof(*tree), CompareHuffmanTrees); qsort(tree, tree_size, sizeof(*tree), CompareHuffmanTrees);
if (tree_size > 1) { // Normal case. if (tree_size > 1) { // Normal case.
int tree_pool_size = 0; int tree_pool_size = 0;
@ -147,8 +144,8 @@ int VP8LCreateHuffmanTree(const int* const histogram, int histogram_size,
} }
SetBitDepths(&tree[0], tree_pool, bit_depths, 0); SetBitDepths(&tree[0], tree_pool, bit_depths, 0);
} else if (tree_size == 1) { // Trivial case: only one element. } else if (tree_size == 1) { // Trivial case: only one element.
bit_depths[tree[0].value_] = 1; bit_depths[tree[0].value_] = 1;
} }
{ {
// Test if this Huffman tree satisfies our 'tree_depth_limit' criteria. // Test if this Huffman tree satisfies our 'tree_depth_limit' criteria.