| OLD | NEW |
| 1 // Copyright 2011 Google Inc. All Rights Reserved. | 1 // Copyright 2011 Google Inc. All Rights Reserved. |
| 2 // | 2 // |
| 3 // This code is licensed under the same terms as WebM: | 3 // Use of this source code is governed by a BSD-style license |
| 4 // Software License Agreement: http://www.webmproject.org/license/software/ | 4 // that can be found in the COPYING file in the root of the source |
| 5 // Additional IP Rights Grant: http://www.webmproject.org/license/additional/ | 5 // tree. An additional intellectual property rights grant can be found |
| 6 // in the file PATENTS. All contributing project authors may |
| 7 // be found in the AUTHORS file in the root of the source tree. |
| 6 // ----------------------------------------------------------------------------- | 8 // ----------------------------------------------------------------------------- |
| 7 // | 9 // |
| 8 // WebPPicture utils: colorspace conversion, crop, ... | 10 // WebPPicture utils: colorspace conversion, crop, ... |
| 9 // | 11 // |
| 10 // Author: Skal (pascal.massimino@gmail.com) | 12 // Author: Skal (pascal.massimino@gmail.com) |
| 11 | 13 |
| 12 #include <assert.h> | 14 #include <assert.h> |
| 13 #include <stdlib.h> | 15 #include <stdlib.h> |
| 14 #include <math.h> | 16 #include <math.h> |
| 15 | 17 |
| (...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 702 (b_ptr[offset]); | 704 (b_ptr[offset]); |
| 703 picture->argb[x + y * picture->argb_stride] = argb; | 705 picture->argb[x + y * picture->argb_stride] = argb; |
| 704 } | 706 } |
| 705 } | 707 } |
| 706 } else { | 708 } else { |
| 707 int x, y; | 709 int x, y; |
| 708 assert(step >= 4); | 710 assert(step >= 4); |
| 709 for (y = 0; y < height; ++y) { | 711 for (y = 0; y < height; ++y) { |
| 710 for (x = 0; x < width; ++x) { | 712 for (x = 0; x < width; ++x) { |
| 711 const int offset = step * x + y * rgb_stride; | 713 const int offset = step * x + y * rgb_stride; |
| 712 const uint32_t argb = (a_ptr[offset] << 24) | | 714 const uint32_t argb = ((uint32_t)a_ptr[offset] << 24) | |
| 713 (r_ptr[offset] << 16) | | 715 (r_ptr[offset] << 16) | |
| 714 (g_ptr[offset] << 8) | | 716 (g_ptr[offset] << 8) | |
| 715 (b_ptr[offset]); | 717 (b_ptr[offset]); |
| 716 picture->argb[x + y * picture->argb_stride] = argb; | 718 picture->argb[x + y * picture->argb_stride] = argb; |
| 717 } | 719 } |
| 718 } | 720 } |
| 719 } | 721 } |
| 720 return 1; | 722 return 1; |
| 721 } | 723 } |
| 722 #undef SUM4 | 724 #undef SUM4 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 802 if (height > 1 && !(height & 1)) { | 804 if (height > 1 && !(height & 1)) { |
| 803 upsample(cur_y, NULL, cur_u, cur_v, cur_u, cur_v, dst, NULL, width); | 805 upsample(cur_y, NULL, cur_u, cur_v, cur_u, cur_v, dst, NULL, width); |
| 804 } | 806 } |
| 805 // Insert alpha values if needed, in replacement for the default 0xff ones. | 807 // Insert alpha values if needed, in replacement for the default 0xff ones. |
| 806 if (picture->colorspace & WEBP_CSP_ALPHA_BIT) { | 808 if (picture->colorspace & WEBP_CSP_ALPHA_BIT) { |
| 807 for (y = 0; y < height; ++y) { | 809 for (y = 0; y < height; ++y) { |
| 808 uint32_t* const argb_dst = picture->argb + y * picture->argb_stride; | 810 uint32_t* const argb_dst = picture->argb + y * picture->argb_stride; |
| 809 const uint8_t* const src = picture->a + y * picture->a_stride; | 811 const uint8_t* const src = picture->a + y * picture->a_stride; |
| 810 int x; | 812 int x; |
| 811 for (x = 0; x < width; ++x) { | 813 for (x = 0; x < width; ++x) { |
| 812 argb_dst[x] = (argb_dst[x] & 0x00ffffffu) | (src[x] << 24); | 814 argb_dst[x] = (argb_dst[x] & 0x00ffffffu) | ((uint32_t)src[x] << 24); |
| 813 } | 815 } |
| 814 } | 816 } |
| 815 } | 817 } |
| 816 } | 818 } |
| 817 return 1; | 819 return 1; |
| 818 } | 820 } |
| 819 | 821 |
| 820 int WebPPictureARGBToYUVA(WebPPicture* picture, WebPEncCSP colorspace) { | 822 int WebPPictureARGBToYUVA(WebPPicture* picture, WebPEncCSP colorspace) { |
| 821 if (picture == NULL) return 0; | 823 if (picture == NULL) return 0; |
| 822 if (picture->argb == NULL) { | 824 if (picture->argb == NULL) { |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1104 LOSSLESS_ENCODE_FUNC(WebPEncodeLosslessRGBA, WebPPictureImportRGBA); | 1106 LOSSLESS_ENCODE_FUNC(WebPEncodeLosslessRGBA, WebPPictureImportRGBA); |
| 1105 LOSSLESS_ENCODE_FUNC(WebPEncodeLosslessBGRA, WebPPictureImportBGRA); | 1107 LOSSLESS_ENCODE_FUNC(WebPEncodeLosslessBGRA, WebPPictureImportBGRA); |
| 1106 | 1108 |
| 1107 #undef LOSSLESS_ENCODE_FUNC | 1109 #undef LOSSLESS_ENCODE_FUNC |
| 1108 | 1110 |
| 1109 //------------------------------------------------------------------------------ | 1111 //------------------------------------------------------------------------------ |
| 1110 | 1112 |
| 1111 #if defined(__cplusplus) || defined(c_plusplus) | 1113 #if defined(__cplusplus) || defined(c_plusplus) |
| 1112 } // extern "C" | 1114 } // extern "C" |
| 1113 #endif | 1115 #endif |
| OLD | NEW |