| OLD | NEW |
| 1 // Copyright 2011 Google Inc. All Rights Reserved. | 1 // Copyright 2011 Google Inc. All Rights Reserved. |
| 2 // | 2 // |
| 3 // Use of this source code is governed by a BSD-style license | 3 // Use of this source code is governed by a BSD-style license |
| 4 // that can be found in the COPYING file in the root of the source | 4 // that can be found in the COPYING file in the root of the source |
| 5 // tree. An additional intellectual property rights grant can be found | 5 // tree. An additional intellectual property rights grant can be found |
| 6 // in the file PATENTS. All contributing project authors may | 6 // in the file PATENTS. All contributing project authors may |
| 7 // be found in the AUTHORS file in the root of the source tree. | 7 // be found in the AUTHORS file in the root of the source tree. |
| 8 // ----------------------------------------------------------------------------- | 8 // ----------------------------------------------------------------------------- |
| 9 // | 9 // |
| 10 // Author: Jyrki Alakuijala (jyrki@google.com) | 10 // Author: Jyrki Alakuijala (jyrki@google.com) |
| 11 // | 11 // |
| 12 // Entropy encoding (Huffman) for webp lossless. | 12 // Entropy encoding (Huffman) for webp lossless. |
| 13 | 13 |
| 14 #include <assert.h> | 14 #include <assert.h> |
| 15 #include <stdlib.h> | 15 #include <stdlib.h> |
| 16 #include <string.h> | 16 #include <string.h> |
| 17 #include "./huffman_encode.h" | 17 #include "./huffman_encode_utils.h" |
| 18 #include "./utils.h" | 18 #include "./utils.h" |
| 19 #include "../webp/format_constants.h" | 19 #include "../webp/format_constants.h" |
| 20 | 20 |
| 21 // ----------------------------------------------------------------------------- | 21 // ----------------------------------------------------------------------------- |
| 22 // Util function to optimize the symbol map for RLE coding | 22 // Util function to optimize the symbol map for RLE coding |
| 23 | 23 |
| 24 // Heuristics for selecting the stride ranges to collapse. | 24 // Heuristics for selecting the stride ranges to collapse. |
| 25 static int ValuesShouldBeCollapsedToStrideAverage(int a, int b) { | 25 static int ValuesShouldBeCollapsedToStrideAverage(int a, int b) { |
| 26 return abs(a - b) < 4; | 26 return abs(a - b) < 4; |
| 27 } | 27 } |
| (...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 408 HuffmanTree* const huff_tree, | 408 HuffmanTree* const huff_tree, |
| 409 HuffmanTreeCode* const huff_code) { | 409 HuffmanTreeCode* const huff_code) { |
| 410 const int num_symbols = huff_code->num_symbols; | 410 const int num_symbols = huff_code->num_symbols; |
| 411 memset(buf_rle, 0, num_symbols * sizeof(*buf_rle)); | 411 memset(buf_rle, 0, num_symbols * sizeof(*buf_rle)); |
| 412 OptimizeHuffmanForRle(num_symbols, buf_rle, histogram); | 412 OptimizeHuffmanForRle(num_symbols, buf_rle, histogram); |
| 413 GenerateOptimalTree(histogram, num_symbols, huff_tree, tree_depth_limit, | 413 GenerateOptimalTree(histogram, num_symbols, huff_tree, tree_depth_limit, |
| 414 huff_code->code_lengths); | 414 huff_code->code_lengths); |
| 415 // Create the actual bit codes for the bit lengths. | 415 // Create the actual bit codes for the bit lengths. |
| 416 ConvertBitDepthsToSymbols(huff_code); | 416 ConvertBitDepthsToSymbols(huff_code); |
| 417 } | 417 } |
| OLD | NEW |