| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 828 } | 828 } |
| 829 int width = image->comps[0].w; | 829 int width = image->comps[0].w; |
| 830 int height = image->comps[0].h; | 830 int height = image->comps[0].h; |
| 831 for (uint32_t channel = 0; channel < image->numcomps; ++channel) { | 831 for (uint32_t channel = 0; channel < image->numcomps; ++channel) { |
| 832 uint8_t* pChannel = channel_bufs[channel]; | 832 uint8_t* pChannel = channel_bufs[channel]; |
| 833 if (adjust_comps[channel] < 0) { | 833 if (adjust_comps[channel] < 0) { |
| 834 for (int row = 0; row < height; ++row) { | 834 for (int row = 0; row < height; ++row) { |
| 835 uint8_t* pScanline = pChannel + row * pitch; | 835 uint8_t* pScanline = pChannel + row * pitch; |
| 836 for (int col = 0; col < width; ++col) { | 836 for (int col = 0; col < width; ++col) { |
| 837 uint8_t* pPixel = pScanline + col * image->numcomps; | 837 uint8_t* pPixel = pScanline + col * image->numcomps; |
| 838 if (!image->comps[channel].data) |
| 839 continue; |
| 840 |
| 838 int src = image->comps[channel].data[row * width + col]; | 841 int src = image->comps[channel].data[row * width + col]; |
| 839 src += image->comps[channel].sgnd | 842 src += image->comps[channel].sgnd |
| 840 ? 1 << (image->comps[channel].prec - 1) | 843 ? 1 << (image->comps[channel].prec - 1) |
| 841 : 0; | 844 : 0; |
| 842 if (adjust_comps[channel] > 0) { | 845 if (adjust_comps[channel] > 0) { |
| 843 *pPixel = 0; | 846 *pPixel = 0; |
| 844 } else { | 847 } else { |
| 845 *pPixel = (uint8_t)(src << -adjust_comps[channel]); | 848 *pPixel = (uint8_t)(src << -adjust_comps[channel]); |
| 846 } | 849 } |
| 847 } | 850 } |
| 848 } | 851 } |
| 849 } else { | 852 } else { |
| 850 for (int row = 0; row < height; ++row) { | 853 for (int row = 0; row < height; ++row) { |
| 851 uint8_t* pScanline = pChannel + row * pitch; | 854 uint8_t* pScanline = pChannel + row * pitch; |
| 852 for (int col = 0; col < width; ++col) { | 855 for (int col = 0; col < width; ++col) { |
| 853 uint8_t* pPixel = pScanline + col * image->numcomps; | 856 uint8_t* pPixel = pScanline + col * image->numcomps; |
| 854 if (!image->comps[channel].data) { | 857 if (!image->comps[channel].data) |
| 855 continue; | 858 continue; |
| 856 } | 859 |
| 857 int src = image->comps[channel].data[row * width + col]; | 860 int src = image->comps[channel].data[row * width + col]; |
| 858 src += image->comps[channel].sgnd | 861 src += image->comps[channel].sgnd |
| 859 ? 1 << (image->comps[channel].prec - 1) | 862 ? 1 << (image->comps[channel].prec - 1) |
| 860 : 0; | 863 : 0; |
| 861 if (adjust_comps[channel] - 1 < 0) { | 864 if (adjust_comps[channel] - 1 < 0) { |
| 862 *pPixel = (uint8_t)((src >> adjust_comps[channel])); | 865 *pPixel = (uint8_t)((src >> adjust_comps[channel])); |
| 863 } else { | 866 } else { |
| 864 int tmpPixel = (src >> adjust_comps[channel]) + | 867 int tmpPixel = (src >> adjust_comps[channel]) + |
| 865 ((src >> (adjust_comps[channel] - 1)) % 2); | 868 ((src >> (adjust_comps[channel] - 1)) % 2); |
| 866 if (tmpPixel > 255) { | 869 if (tmpPixel > 255) { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 897 bool CCodec_JpxModule::Decode(CJPX_Decoder* pDecoder, | 900 bool CCodec_JpxModule::Decode(CJPX_Decoder* pDecoder, |
| 898 uint8_t* dest_data, | 901 uint8_t* dest_data, |
| 899 int pitch, | 902 int pitch, |
| 900 const std::vector<uint8_t>& offsets) { | 903 const std::vector<uint8_t>& offsets) { |
| 901 return pDecoder->Decode(dest_data, pitch, offsets); | 904 return pDecoder->Decode(dest_data, pitch, offsets); |
| 902 } | 905 } |
| 903 | 906 |
| 904 void CCodec_JpxModule::DestroyDecoder(CJPX_Decoder* pDecoder) { | 907 void CCodec_JpxModule::DestroyDecoder(CJPX_Decoder* pDecoder) { |
| 905 delete pDecoder; | 908 delete pDecoder; |
| 906 } | 909 } |
| OLD | NEW |