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 // WebPPicture class basis | 10 // WebPPicture class basis |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 typedef int (*Importer)(WebPPicture* const, const uint8_t* const, int); | 230 typedef int (*Importer)(WebPPicture* const, const uint8_t* const, int); |
231 | 231 |
232 static size_t Encode(const uint8_t* rgba, int width, int height, int stride, | 232 static size_t Encode(const uint8_t* rgba, int width, int height, int stride, |
233 Importer import, float quality_factor, int lossless, | 233 Importer import, float quality_factor, int lossless, |
234 uint8_t** output) { | 234 uint8_t** output) { |
235 WebPPicture pic; | 235 WebPPicture pic; |
236 WebPConfig config; | 236 WebPConfig config; |
237 WebPMemoryWriter wrt; | 237 WebPMemoryWriter wrt; |
238 int ok; | 238 int ok; |
239 | 239 |
| 240 if (output == NULL) return 0; |
| 241 |
240 if (!WebPConfigPreset(&config, WEBP_PRESET_DEFAULT, quality_factor) || | 242 if (!WebPConfigPreset(&config, WEBP_PRESET_DEFAULT, quality_factor) || |
241 !WebPPictureInit(&pic)) { | 243 !WebPPictureInit(&pic)) { |
242 return 0; // shouldn't happen, except if system installation is broken | 244 return 0; // shouldn't happen, except if system installation is broken |
243 } | 245 } |
244 | 246 |
245 config.lossless = !!lossless; | 247 config.lossless = !!lossless; |
246 pic.use_argb = !!lossless; | 248 pic.use_argb = !!lossless; |
247 pic.width = width; | 249 pic.width = width; |
248 pic.height = height; | 250 pic.height = height; |
249 pic.writer = WebPMemoryWrite; | 251 pic.writer = WebPMemoryWrite; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 } | 283 } |
282 | 284 |
283 LOSSLESS_ENCODE_FUNC(WebPEncodeLosslessRGB, WebPPictureImportRGB) | 285 LOSSLESS_ENCODE_FUNC(WebPEncodeLosslessRGB, WebPPictureImportRGB) |
284 LOSSLESS_ENCODE_FUNC(WebPEncodeLosslessBGR, WebPPictureImportBGR) | 286 LOSSLESS_ENCODE_FUNC(WebPEncodeLosslessBGR, WebPPictureImportBGR) |
285 LOSSLESS_ENCODE_FUNC(WebPEncodeLosslessRGBA, WebPPictureImportRGBA) | 287 LOSSLESS_ENCODE_FUNC(WebPEncodeLosslessRGBA, WebPPictureImportRGBA) |
286 LOSSLESS_ENCODE_FUNC(WebPEncodeLosslessBGRA, WebPPictureImportBGRA) | 288 LOSSLESS_ENCODE_FUNC(WebPEncodeLosslessBGRA, WebPPictureImportBGRA) |
287 | 289 |
288 #undef LOSSLESS_ENCODE_FUNC | 290 #undef LOSSLESS_ENCODE_FUNC |
289 | 291 |
290 //------------------------------------------------------------------------------ | 292 //------------------------------------------------------------------------------ |
OLD | NEW |