OLD | NEW |
1 // Copyright 2012 Google Inc. All Rights Reserved. | 1 // Copyright 2012 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 // Utilities for building and looking up Huffman trees. | 10 // Utilities for building and looking up Huffman trees. |
11 // | 11 // |
12 // Author: Urvang Joshi (urvang@google.com) | 12 // Author: Urvang Joshi (urvang@google.com) |
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.h" | 17 #include "./huffman.h" |
18 #include "../utils/utils.h" | 18 #include "./utils.h" |
19 #include "../webp/format_constants.h" | 19 #include "../webp/format_constants.h" |
20 | 20 |
21 // Huffman data read via DecodeImageStream is represented in two (red and green) | 21 // Huffman data read via DecodeImageStream is represented in two (red and green) |
22 // bytes. | 22 // bytes. |
23 #define MAX_HTREE_GROUPS 0x10000 | 23 #define MAX_HTREE_GROUPS 0x10000 |
24 | 24 |
25 HTreeGroup* VP8LHtreeGroupsNew(int num_htree_groups) { | 25 HTreeGroup* VP8LHtreeGroupsNew(int num_htree_groups) { |
26 HTreeGroup* const htree_groups = | 26 HTreeGroup* const htree_groups = |
27 (HTreeGroup*)WebPSafeMalloc(num_htree_groups, sizeof(*htree_groups)); | 27 (HTreeGroup*)WebPSafeMalloc(num_htree_groups, sizeof(*htree_groups)); |
28 if (htree_groups == NULL) { | 28 if (htree_groups == NULL) { |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 // Check if tree is full. | 196 // Check if tree is full. |
197 if (num_nodes != 2 * offset[MAX_ALLOWED_CODE_LENGTH] - 1) { | 197 if (num_nodes != 2 * offset[MAX_ALLOWED_CODE_LENGTH] - 1) { |
198 WebPSafeFree(sorted); | 198 WebPSafeFree(sorted); |
199 return 0; | 199 return 0; |
200 } | 200 } |
201 } | 201 } |
202 | 202 |
203 WebPSafeFree(sorted); | 203 WebPSafeFree(sorted); |
204 return total_size; | 204 return total_size; |
205 } | 205 } |
OLD | NEW |