Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2011 Google Inc. | 1 // Copyright 2011 Google Inc. |
| 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 // WebPPicture utils: colorspace conversion, crop, ... | 8 // WebPPicture utils: colorspace conversion, crop, ... |
| 9 // | 9 // |
| 10 // Author: Skal (pascal.massimino@gmail.com) | 10 // Author: Skal (pascal.massimino@gmail.com) |
| (...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 586 return Import(picture, rgba, rgba_stride, 4, 0, 1); | 586 return Import(picture, rgba, rgba_stride, 4, 0, 1); |
| 587 } | 587 } |
| 588 | 588 |
| 589 int WebPPictureImportBGRA(WebPPicture* const picture, | 589 int WebPPictureImportBGRA(WebPPicture* const picture, |
| 590 const uint8_t* const rgba, int rgba_stride) { | 590 const uint8_t* const rgba, int rgba_stride) { |
| 591 picture->colorspace |= WEBP_CSP_ALPHA_BIT; | 591 picture->colorspace |= WEBP_CSP_ALPHA_BIT; |
| 592 if (!WebPPictureAlloc(picture)) return 0; | 592 if (!WebPPictureAlloc(picture)) return 0; |
| 593 return Import(picture, rgba, rgba_stride, 4, 1, 1); | 593 return Import(picture, rgba, rgba_stride, 4, 1, 1); |
| 594 } | 594 } |
| 595 | 595 |
| 596 int WebPPictureImportRGBX(WebPPicture* const picture, | |
| 597 const uint8_t* const rgbx, int rgbx_stride) { | |
| 598 // In libwebp.next, assert picture->user_argb_input here. | |
|
skal
2012/06/04 04:34:55
not necessarily. What if you want to convert to YU
| |
| 599 picture->colorspace &= ~WEBP_CSP_ALPHA_BIT; | |
| 600 if (!WebPPictureAlloc(picture)) return 0; | |
| 601 return Import(picture, rgbx, rgbx_stride, 4, 0, 0); | |
| 602 } | |
| 603 | |
| 604 int WebPPictureImportBGRX(WebPPicture* const picture, | |
| 605 const uint8_t* const rgbx, int rgbx_stride) { | |
| 606 // In libwebp.next, assert picture->user_argb_input here. | |
|
skal
2012/06/04 04:34:55
here too
| |
| 607 picture->colorspace &= ~WEBP_CSP_ALPHA_BIT; | |
| 608 if (!WebPPictureAlloc(picture)) return 0; | |
| 609 return Import(picture, rgbx, rgbx_stride, 4, 1, 0); | |
| 610 } | |
| 611 | |
| 596 //------------------------------------------------------------------------------ | 612 //------------------------------------------------------------------------------ |
| 597 // Simplest call: | 613 // Simplest call: |
| 598 | 614 |
| 599 typedef int (*Importer)(WebPPicture* const, const uint8_t* const, int); | 615 typedef int (*Importer)(WebPPicture* const, const uint8_t* const, int); |
| 600 | 616 |
| 601 static size_t Encode(const uint8_t* rgba, int width, int height, int stride, | 617 static size_t Encode(const uint8_t* rgba, int width, int height, int stride, |
| 602 Importer import, float quality_factor, uint8_t** output) { | 618 Importer import, float quality_factor, uint8_t** output) { |
| 603 size_t output_size = 0; | 619 size_t output_size = 0; |
| 604 WebPPicture pic; | 620 WebPPicture pic; |
| 605 WebPConfig config; | 621 WebPConfig config; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 641 ENCODE_FUNC(WebPEncodeRGBA, WebPPictureImportRGBA); | 657 ENCODE_FUNC(WebPEncodeRGBA, WebPPictureImportRGBA); |
| 642 ENCODE_FUNC(WebPEncodeBGRA, WebPPictureImportBGRA); | 658 ENCODE_FUNC(WebPEncodeBGRA, WebPPictureImportBGRA); |
| 643 | 659 |
| 644 #undef ENCODE_FUNC | 660 #undef ENCODE_FUNC |
| 645 | 661 |
| 646 //------------------------------------------------------------------------------ | 662 //------------------------------------------------------------------------------ |
| 647 | 663 |
| 648 #if defined(__cplusplus) || defined(c_plusplus) | 664 #if defined(__cplusplus) || defined(c_plusplus) |
| 649 } // extern "C" | 665 } // extern "C" |
| 650 #endif | 666 #endif |
| OLD | NEW |