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 // Author: Jyrki Alakuijala (jyrki@google.com) | 10 // Author: Jyrki Alakuijala (jyrki@google.com) |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 const PixOrCopy* const v) { | 83 const PixOrCopy* const v) { |
84 if (PixOrCopyIsLiteral(v)) { | 84 if (PixOrCopyIsLiteral(v)) { |
85 ++histo->alpha_[PixOrCopyLiteral(v, 3)]; | 85 ++histo->alpha_[PixOrCopyLiteral(v, 3)]; |
86 ++histo->red_[PixOrCopyLiteral(v, 2)]; | 86 ++histo->red_[PixOrCopyLiteral(v, 2)]; |
87 ++histo->literal_[PixOrCopyLiteral(v, 1)]; | 87 ++histo->literal_[PixOrCopyLiteral(v, 1)]; |
88 ++histo->blue_[PixOrCopyLiteral(v, 0)]; | 88 ++histo->blue_[PixOrCopyLiteral(v, 0)]; |
89 } else if (PixOrCopyIsCacheIdx(v)) { | 89 } else if (PixOrCopyIsCacheIdx(v)) { |
90 int literal_ix = 256 + NUM_LENGTH_CODES + PixOrCopyCacheIdx(v); | 90 int literal_ix = 256 + NUM_LENGTH_CODES + PixOrCopyCacheIdx(v); |
91 ++histo->literal_[literal_ix]; | 91 ++histo->literal_[literal_ix]; |
92 } else { | 92 } else { |
93 int code, extra_bits_count, extra_bits_value; | 93 int code, extra_bits; |
94 PrefixEncode(PixOrCopyLength(v), | 94 VP8LPrefixEncodeBits(PixOrCopyLength(v), &code, &extra_bits); |
95 &code, &extra_bits_count, &extra_bits_value); | |
96 ++histo->literal_[256 + code]; | 95 ++histo->literal_[256 + code]; |
97 PrefixEncode(PixOrCopyDistance(v), | 96 VP8LPrefixEncodeBits(PixOrCopyDistance(v), &code, &extra_bits); |
98 &code, &extra_bits_count, &extra_bits_value); | |
99 ++histo->distance_[code]; | 97 ++histo->distance_[code]; |
100 } | 98 } |
101 } | 99 } |
102 | 100 |
103 static double BitsEntropy(const int* const array, int n) { | 101 static double BitsEntropy(const int* const array, int n) { |
104 double retval = 0.; | 102 double retval = 0.; |
105 int sum = 0; | 103 int sum = 0; |
106 int nonzeros = 0; | 104 int nonzeros = 0; |
107 int max_val = 0; | 105 int max_val = 0; |
108 int i; | 106 int i; |
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
505 goto Error; | 503 goto Error; |
506 } | 504 } |
507 // Find the optimal map from original histograms to the final ones. | 505 // Find the optimal map from original histograms to the final ones. |
508 HistogramRemap(image_out, image_in, histogram_symbols); | 506 HistogramRemap(image_out, image_in, histogram_symbols); |
509 ok = 1; | 507 ok = 1; |
510 | 508 |
511 Error: | 509 Error: |
512 free(image_out); | 510 free(image_out); |
513 return ok; | 511 return ok; |
514 } | 512 } |
OLD | NEW |