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 // Coding tools configuration | 10 // Coding tools configuration |
(...skipping 25 matching lines...) Expand all Loading... |
36 config->segments = 4; | 36 config->segments = 4; |
37 config->pass = 1; | 37 config->pass = 1; |
38 config->show_compressed = 0; | 38 config->show_compressed = 0; |
39 config->preprocessing = 0; | 39 config->preprocessing = 0; |
40 config->autofilter = 0; | 40 config->autofilter = 0; |
41 config->partition_limit = 0; | 41 config->partition_limit = 0; |
42 config->alpha_compression = 1; | 42 config->alpha_compression = 1; |
43 config->alpha_filtering = 1; | 43 config->alpha_filtering = 1; |
44 config->alpha_quality = 100; | 44 config->alpha_quality = 100; |
45 config->lossless = 0; | 45 config->lossless = 0; |
| 46 config->exact = 0; |
46 config->image_hint = WEBP_HINT_DEFAULT; | 47 config->image_hint = WEBP_HINT_DEFAULT; |
47 config->emulate_jpeg_size = 0; | 48 config->emulate_jpeg_size = 0; |
48 config->thread_level = 0; | 49 config->thread_level = 0; |
49 config->low_memory = 0; | 50 config->low_memory = 0; |
| 51 config->near_lossless = 100; |
| 52 #ifdef WEBP_EXPERIMENTAL_FEATURES |
| 53 config->delta_palettization = 0; |
| 54 #endif // WEBP_EXPERIMENTAL_FEATURES |
50 | 55 |
51 // TODO(skal): tune. | 56 // TODO(skal): tune. |
52 switch (preset) { | 57 switch (preset) { |
53 case WEBP_PRESET_PICTURE: | 58 case WEBP_PRESET_PICTURE: |
54 config->sns_strength = 80; | 59 config->sns_strength = 80; |
55 config->filter_sharpness = 4; | 60 config->filter_sharpness = 4; |
56 config->filter_strength = 35; | 61 config->filter_strength = 35; |
57 config->preprocessing &= ~2; // no dithering | 62 config->preprocessing &= ~2; // no dithering |
58 break; | 63 break; |
59 case WEBP_PRESET_PHOTO: | 64 case WEBP_PRESET_PHOTO: |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 if (config->filter_sharpness < 0 || config->filter_sharpness > 7) | 109 if (config->filter_sharpness < 0 || config->filter_sharpness > 7) |
105 return 0; | 110 return 0; |
106 if (config->filter_type < 0 || config->filter_type > 1) | 111 if (config->filter_type < 0 || config->filter_type > 1) |
107 return 0; | 112 return 0; |
108 if (config->autofilter < 0 || config->autofilter > 1) | 113 if (config->autofilter < 0 || config->autofilter > 1) |
109 return 0; | 114 return 0; |
110 if (config->pass < 1 || config->pass > 10) | 115 if (config->pass < 1 || config->pass > 10) |
111 return 0; | 116 return 0; |
112 if (config->show_compressed < 0 || config->show_compressed > 1) | 117 if (config->show_compressed < 0 || config->show_compressed > 1) |
113 return 0; | 118 return 0; |
114 #if WEBP_ENCODER_ABI_VERSION > 0x0204 | |
115 if (config->preprocessing < 0 || config->preprocessing > 7) | 119 if (config->preprocessing < 0 || config->preprocessing > 7) |
116 #else | |
117 if (config->preprocessing < 0 || config->preprocessing > 3) | |
118 #endif | |
119 return 0; | 120 return 0; |
120 if (config->partitions < 0 || config->partitions > 3) | 121 if (config->partitions < 0 || config->partitions > 3) |
121 return 0; | 122 return 0; |
122 if (config->partition_limit < 0 || config->partition_limit > 100) | 123 if (config->partition_limit < 0 || config->partition_limit > 100) |
123 return 0; | 124 return 0; |
124 if (config->alpha_compression < 0) | 125 if (config->alpha_compression < 0) |
125 return 0; | 126 return 0; |
126 if (config->alpha_filtering < 0) | 127 if (config->alpha_filtering < 0) |
127 return 0; | 128 return 0; |
128 if (config->alpha_quality < 0 || config->alpha_quality > 100) | 129 if (config->alpha_quality < 0 || config->alpha_quality > 100) |
129 return 0; | 130 return 0; |
130 if (config->lossless < 0 || config->lossless > 1) | 131 if (config->lossless < 0 || config->lossless > 1) |
131 return 0; | 132 return 0; |
| 133 if (config->near_lossless < 0 || config->near_lossless > 100) |
| 134 return 0; |
132 if (config->image_hint >= WEBP_HINT_LAST) | 135 if (config->image_hint >= WEBP_HINT_LAST) |
133 return 0; | 136 return 0; |
134 if (config->emulate_jpeg_size < 0 || config->emulate_jpeg_size > 1) | 137 if (config->emulate_jpeg_size < 0 || config->emulate_jpeg_size > 1) |
135 return 0; | 138 return 0; |
136 if (config->thread_level < 0 || config->thread_level > 1) | 139 if (config->thread_level < 0 || config->thread_level > 1) |
137 return 0; | 140 return 0; |
138 if (config->low_memory < 0 || config->low_memory > 1) | 141 if (config->low_memory < 0 || config->low_memory > 1) |
139 return 0; | 142 return 0; |
| 143 if (config->exact < 0 || config->exact > 1) |
| 144 return 0; |
| 145 #ifdef WEBP_EXPERIMENTAL_FEATURES |
| 146 if (config->delta_palettization < 0 || config->delta_palettization > 1) |
| 147 return 0; |
| 148 #endif // WEBP_EXPERIMENTAL_FEATURES |
140 return 1; | 149 return 1; |
141 } | 150 } |
142 | 151 |
143 //------------------------------------------------------------------------------ | 152 //------------------------------------------------------------------------------ |
144 | 153 |
145 #if WEBP_ENCODER_ABI_VERSION > 0x0202 | |
146 #define MAX_LEVEL 9 | 154 #define MAX_LEVEL 9 |
147 | 155 |
148 // Mapping between -z level and -m / -q parameter settings. | 156 // Mapping between -z level and -m / -q parameter settings. |
149 static const struct { | 157 static const struct { |
150 uint8_t method_; | 158 uint8_t method_; |
151 uint8_t quality_; | 159 uint8_t quality_; |
152 } kLosslessPresets[MAX_LEVEL + 1] = { | 160 } kLosslessPresets[MAX_LEVEL + 1] = { |
153 { 0, 0 }, { 1, 20 }, { 2, 25 }, { 3, 30 }, { 3, 50 }, | 161 { 0, 0 }, { 1, 20 }, { 2, 25 }, { 3, 30 }, { 3, 50 }, |
154 { 4, 50 }, { 4, 75 }, { 4, 90 }, { 5, 90 }, { 6, 100 } | 162 { 4, 50 }, { 4, 75 }, { 4, 90 }, { 5, 90 }, { 6, 100 } |
155 }; | 163 }; |
156 | 164 |
157 int WebPConfigLosslessPreset(WebPConfig* config, int level) { | 165 int WebPConfigLosslessPreset(WebPConfig* config, int level) { |
158 if (config == NULL || level < 0 || level > MAX_LEVEL) return 0; | 166 if (config == NULL || level < 0 || level > MAX_LEVEL) return 0; |
159 config->lossless = 1; | 167 config->lossless = 1; |
160 config->method = kLosslessPresets[level].method_; | 168 config->method = kLosslessPresets[level].method_; |
161 config->quality = kLosslessPresets[level].quality_; | 169 config->quality = kLosslessPresets[level].quality_; |
162 return 1; | 170 return 1; |
163 } | 171 } |
164 #endif | |
165 | 172 |
166 //------------------------------------------------------------------------------ | 173 //------------------------------------------------------------------------------ |
OLD | NEW |