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 | 9 |
10 #include "../../../include/fxcodec/fx_codec.h" | 10 #include "../../../include/fxcodec/fx_codec.h" |
(...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
708 FX_LPBYTE pChannel, pScanline, pPixel; | 708 FX_LPBYTE pChannel, pScanline, pPixel; |
709 | 709 |
710 if(image->comps[0].w != image->x1 || image->comps[0].h != image->y1) { | 710 if(image->comps[0].w != image->x1 || image->comps[0].h != image->y1) { |
711 return FALSE; | 711 return FALSE; |
712 } | 712 } |
713 if(pitch < (int)(image->comps[0].w * 8 * image->numcomps + 31) >> 5 << 2) { | 713 if(pitch < (int)(image->comps[0].w * 8 * image->numcomps + 31) >> 5 << 2) { |
714 return FALSE; | 714 return FALSE; |
715 } | 715 } |
716 FXSYS_memset8(dest_buf, 0xff, image->y1 * pitch); | 716 FXSYS_memset8(dest_buf, 0xff, image->y1 * pitch); |
717 FX_BYTE** channel_bufs = FX_Alloc(FX_BYTE*, image->numcomps); | 717 FX_BYTE** channel_bufs = FX_Alloc(FX_BYTE*, image->numcomps); |
| 718 if (channel_bufs == NULL) { |
| 719 return FALSE; |
| 720 } |
718 FX_BOOL result = FALSE; | 721 FX_BOOL result = FALSE; |
719 int* adjust_comps = FX_Alloc(int, image->numcomps); | 722 int* adjust_comps = FX_Alloc(int, image->numcomps); |
| 723 if (adjust_comps == NULL) { |
| 724 goto done; |
| 725 } |
720 for (i = 0; i < (int)image->numcomps; i ++) { | 726 for (i = 0; i < (int)image->numcomps; i ++) { |
721 channel_bufs[i] = dest_buf + offsets[i]; | 727 channel_bufs[i] = dest_buf + offsets[i]; |
722 adjust_comps[i] = image->comps[i].prec - 8; | 728 adjust_comps[i] = image->comps[i].prec - 8; |
723 if(i > 0) { | 729 if(i > 0) { |
724 if(image->comps[i].dx != image->comps[i - 1].dx | 730 if(image->comps[i].dx != image->comps[i - 1].dx |
725 || image->comps[i].dy != image->comps[i - 1].dy | 731 || image->comps[i].dy != image->comps[i - 1].dy |
726 || image->comps[i].prec != image->comps[i - 1].prec) { | 732 || image->comps[i].prec != image->comps[i - 1].prec) { |
727 goto done; | 733 goto done; |
728 } | 734 } |
729 } | 735 } |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
803 FX_BOOL CCodec_JpxModule::Decode(void* ctx, FX_LPBYTE dest_data, int pitch, FX_B
OOL bTranslateColor, FX_LPBYTE offsets) | 809 FX_BOOL CCodec_JpxModule::Decode(void* ctx, FX_LPBYTE dest_data, int pitch, FX_B
OOL bTranslateColor, FX_LPBYTE offsets) |
804 { | 810 { |
805 CJPX_Decoder* pDecoder = (CJPX_Decoder*)ctx; | 811 CJPX_Decoder* pDecoder = (CJPX_Decoder*)ctx; |
806 return pDecoder->Decode(dest_data, pitch, bTranslateColor, offsets); | 812 return pDecoder->Decode(dest_data, pitch, bTranslateColor, offsets); |
807 } | 813 } |
808 void CCodec_JpxModule::DestroyDecoder(void* ctx) | 814 void CCodec_JpxModule::DestroyDecoder(void* ctx) |
809 { | 815 { |
810 CJPX_Decoder* pDecoder = (CJPX_Decoder*)ctx; | 816 CJPX_Decoder* pDecoder = (CJPX_Decoder*)ctx; |
811 delete pDecoder; | 817 delete pDecoder; |
812 } | 818 } |
OLD | NEW |