| 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 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 (img->comps[0].h + 1) / 2 == img->comps[1].h); | 224 (img->comps[0].h + 1) / 2 == img->comps[1].h); |
| 225 } | 225 } |
| 226 static bool sycc422_size_is_valid(opj_image_t* img) { | 226 static bool sycc422_size_is_valid(opj_image_t* img) { |
| 227 return (sycc420_422_size_is_valid(img) && img->comps[0].h == img->comps[1].h); | 227 return (sycc420_422_size_is_valid(img) && img->comps[0].h == img->comps[1].h); |
| 228 } | 228 } |
| 229 static void sycc422_to_rgb(opj_image_t* img) { | 229 static void sycc422_to_rgb(opj_image_t* img) { |
| 230 if (!sycc422_size_is_valid(img)) | 230 if (!sycc422_size_is_valid(img)) |
| 231 return; | 231 return; |
| 232 | 232 |
| 233 int prec = img->comps[0].prec; | 233 int prec = img->comps[0].prec; |
| 234 if (prec <= 0 || prec >= 32) |
| 235 return; |
| 236 |
| 234 int offset = 1 << (prec - 1); | 237 int offset = 1 << (prec - 1); |
| 235 int upb = (1 << prec) - 1; | 238 int upb = (1 << prec) - 1; |
| 236 | 239 |
| 237 OPJ_UINT32 maxw = img->comps[0].w; | 240 OPJ_UINT32 maxw = img->comps[0].w; |
| 238 OPJ_UINT32 maxh = img->comps[0].h; | 241 OPJ_UINT32 maxh = img->comps[0].h; |
| 239 FX_SAFE_SIZE_T max_size = maxw; | 242 FX_SAFE_SIZE_T max_size = maxw; |
| 240 max_size *= maxh; | 243 max_size *= maxh; |
| 241 if (!max_size.IsValid()) | 244 if (!max_size.IsValid()) |
| 242 return; | 245 return; |
| 243 | 246 |
| (...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 900 bool CCodec_JpxModule::Decode(CJPX_Decoder* pDecoder, | 903 bool CCodec_JpxModule::Decode(CJPX_Decoder* pDecoder, |
| 901 uint8_t* dest_data, | 904 uint8_t* dest_data, |
| 902 int pitch, | 905 int pitch, |
| 903 const std::vector<uint8_t>& offsets) { | 906 const std::vector<uint8_t>& offsets) { |
| 904 return pDecoder->Decode(dest_data, pitch, offsets); | 907 return pDecoder->Decode(dest_data, pitch, offsets); |
| 905 } | 908 } |
| 906 | 909 |
| 907 void CCodec_JpxModule::DestroyDecoder(CJPX_Decoder* pDecoder) { | 910 void CCodec_JpxModule::DestroyDecoder(CJPX_Decoder* pDecoder) { |
| 908 delete pDecoder; | 911 delete pDecoder; |
| 909 } | 912 } |
| OLD | NEW |