Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(379)

Side by Side Diff: third_party/libwebp/enc/config.c

Issue 10832153: libwebp: update snapshot to v0.2.0-rc1 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2011 Google Inc. 1 // Copyright 2011 Google Inc. All Rights Reserved.
2 // 2 //
3 // This code is licensed under the same terms as WebM: 3 // This code is licensed under the same terms as WebM:
4 // Software License Agreement: http://www.webmproject.org/license/software/ 4 // Software License Agreement: http://www.webmproject.org/license/software/
5 // Additional IP Rights Grant: http://www.webmproject.org/license/additional/ 5 // Additional IP Rights Grant: http://www.webmproject.org/license/additional/
6 // ----------------------------------------------------------------------------- 6 // -----------------------------------------------------------------------------
7 // 7 //
8 // Coding tools configuration 8 // Coding tools configuration
9 // 9 //
10 // Author: Skal (pascal.massimino@gmail.com) 10 // Author: Skal (pascal.massimino@gmail.com)
11 11
12 #include <assert.h>
13 #include "../webp/encode.h" 12 #include "../webp/encode.h"
14 13
15 #if defined(__cplusplus) || defined(c_plusplus) 14 #if defined(__cplusplus) || defined(c_plusplus)
16 extern "C" { 15 extern "C" {
17 #endif 16 #endif
18 17
19 //------------------------------------------------------------------------------ 18 //------------------------------------------------------------------------------
20 // WebPConfig 19 // WebPConfig
21 //------------------------------------------------------------------------------ 20 //------------------------------------------------------------------------------
22 21
23 int WebPConfigInitInternal(WebPConfig* const config, 22 int WebPConfigInitInternal(WebPConfig* config,
24 WebPPreset preset, float quality, int version) { 23 WebPPreset preset, float quality, int version) {
25 if (version != WEBP_ENCODER_ABI_VERSION) { 24 if (WEBP_ABI_IS_INCOMPATIBLE(version, WEBP_ENCODER_ABI_VERSION)) {
26 return 0; // caller/system version mismatch! 25 return 0; // caller/system version mismatch!
27 } 26 }
28 if (config == NULL) return 0; 27 if (config == NULL) return 0;
29 28
30 config->quality = quality; 29 config->quality = quality;
31 config->target_size = 0; 30 config->target_size = 0;
32 config->target_PSNR = 0.; 31 config->target_PSNR = 0.;
33 config->method = 4; 32 config->method = 4;
34 config->sns_strength = 50; 33 config->sns_strength = 50;
35 config->filter_strength = 20; // default: light filtering 34 config->filter_strength = 20; // default: light filtering
36 config->filter_sharpness = 0; 35 config->filter_sharpness = 0;
37 config->filter_type = 0; // default: simple 36 config->filter_type = 0; // default: simple
38 config->partitions = 0; 37 config->partitions = 0;
39 config->segments = 4; 38 config->segments = 4;
40 config->pass = 1; 39 config->pass = 1;
41 config->show_compressed = 0; 40 config->show_compressed = 0;
42 config->preprocessing = 0; 41 config->preprocessing = 0;
43 config->autofilter = 0; 42 config->autofilter = 0;
44 config->alpha_compression = 0;
45 config->partition_limit = 0; 43 config->partition_limit = 0;
44 config->alpha_compression = 1;
45 config->alpha_filtering = 1;
46 config->alpha_quality = 100;
47 config->lossless = 0;
48 config->image_hint = WEBP_HINT_DEFAULT;
46 49
47 // TODO(skal): tune. 50 // TODO(skal): tune.
48 switch (preset) { 51 switch (preset) {
49 case WEBP_PRESET_PICTURE: 52 case WEBP_PRESET_PICTURE:
50 config->sns_strength = 80; 53 config->sns_strength = 80;
51 config->filter_sharpness = 4; 54 config->filter_sharpness = 4;
52 config->filter_strength = 35; 55 config->filter_strength = 35;
53 break; 56 break;
54 case WEBP_PRESET_PHOTO: 57 case WEBP_PRESET_PHOTO:
55 config->sns_strength = 80; 58 config->sns_strength = 80;
(...skipping 14 matching lines...) Expand all
70 config->filter_strength = 0; // disable filtering to retain sharpness 73 config->filter_strength = 0; // disable filtering to retain sharpness
71 config->segments = 2; 74 config->segments = 2;
72 break; 75 break;
73 case WEBP_PRESET_DEFAULT: 76 case WEBP_PRESET_DEFAULT:
74 default: 77 default:
75 break; 78 break;
76 } 79 }
77 return WebPValidateConfig(config); 80 return WebPValidateConfig(config);
78 } 81 }
79 82
80 int WebPValidateConfig(const WebPConfig* const config) { 83 int WebPValidateConfig(const WebPConfig* config) {
81 if (config == NULL) return 0; 84 if (config == NULL) return 0;
82 if (config->quality < 0 || config->quality > 100) 85 if (config->quality < 0 || config->quality > 100)
83 return 0; 86 return 0;
84 if (config->target_size < 0) 87 if (config->target_size < 0)
85 return 0; 88 return 0;
86 if (config->target_PSNR < 0) 89 if (config->target_PSNR < 0)
87 return 0; 90 return 0;
88 if (config->method < 0 || config->method > 6) 91 if (config->method < 0 || config->method > 6)
89 return 0; 92 return 0;
90 if (config->segments < 1 || config->segments > 4) 93 if (config->segments < 1 || config->segments > 4)
(...skipping 13 matching lines...) Expand all
104 if (config->show_compressed < 0 || config->show_compressed > 1) 107 if (config->show_compressed < 0 || config->show_compressed > 1)
105 return 0; 108 return 0;
106 if (config->preprocessing < 0 || config->preprocessing > 1) 109 if (config->preprocessing < 0 || config->preprocessing > 1)
107 return 0; 110 return 0;
108 if (config->partitions < 0 || config->partitions > 3) 111 if (config->partitions < 0 || config->partitions > 3)
109 return 0; 112 return 0;
110 if (config->partition_limit < 0 || config->partition_limit > 100) 113 if (config->partition_limit < 0 || config->partition_limit > 100)
111 return 0; 114 return 0;
112 if (config->alpha_compression < 0) 115 if (config->alpha_compression < 0)
113 return 0; 116 return 0;
117 if (config->alpha_filtering < 0)
118 return 0;
119 if (config->alpha_quality < 0 || config->alpha_quality > 100)
120 return 0;
121 if (config->lossless < 0 || config->lossless > 1)
122 return 0;
123 if (config->image_hint >= WEBP_HINT_LAST)
124 return 0;
114 return 1; 125 return 1;
115 } 126 }
116 127
117 //------------------------------------------------------------------------------ 128 //------------------------------------------------------------------------------
118 129
119 #if defined(__cplusplus) || defined(c_plusplus) 130 #if defined(__cplusplus) || defined(c_plusplus)
120 } // extern "C" 131 } // extern "C"
121 #endif 132 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698