| 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 "../../../include/fxcodec/fx_codec.h" | 7 #include "../../../include/fxcodec/fx_codec.h" |
| 8 #include "../../../include/fxge/fx_dib.h" | 8 #include "../../../include/fxge/fx_dib.h" |
| 9 #include "codec_int.h" | 9 #include "codec_int.h" |
| 10 extern "C" { | 10 extern "C" { |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 static void _error_do_nothing1(j_common_ptr cinfo, int) {} | 66 static void _error_do_nothing1(j_common_ptr cinfo, int) {} |
| 67 }; | 67 }; |
| 68 extern "C" { | 68 extern "C" { |
| 69 static void _error_do_nothing2(j_common_ptr cinfo, char*) {} | 69 static void _error_do_nothing2(j_common_ptr cinfo, char*) {} |
| 70 }; | 70 }; |
| 71 #define JPEG_MARKER_EXIF (JPEG_APP0 + 1) | 71 #define JPEG_MARKER_EXIF (JPEG_APP0 + 1) |
| 72 #define JPEG_MARKER_ICC (JPEG_APP0 + 2) | 72 #define JPEG_MARKER_ICC (JPEG_APP0 + 2) |
| 73 #define JPEG_MARKER_AUTHORTIME (JPEG_APP0 + 3) | 73 #define JPEG_MARKER_AUTHORTIME (JPEG_APP0 + 3) |
| 74 #define JPEG_MARKER_MAXSIZE 0xFFFF | 74 #define JPEG_MARKER_MAXSIZE 0xFFFF |
| 75 #define JPEG_OVERHEAD_LEN 14 | 75 #define JPEG_OVERHEAD_LEN 14 |
| 76 static FX_BOOL _JpegIsIccMarker(jpeg_saved_marker_ptr marker) | |
| 77 { | |
| 78 if (marker->marker == JPEG_MARKER_ICC && | |
| 79 marker->data_length >= JPEG_OVERHEAD_LEN && | |
| 80 (FXSYS_memcmp32(marker->data, "\x49\x43\x43\x5f\x50\x52\x4f\x46\x49\
x4c\x45\x00", 12) == 0)) { | |
| 81 return TRUE; | |
| 82 } | |
| 83 return FALSE; | |
| 84 } | |
| 85 static FX_BOOL _JpegEmbedIccProfile(j_compress_ptr cinfo, FX_LPCBYTE icc_buf_pt
r, FX_DWORD icc_length) | 76 static FX_BOOL _JpegEmbedIccProfile(j_compress_ptr cinfo, FX_LPCBYTE icc_buf_pt
r, FX_DWORD icc_length) |
| 86 { | 77 { |
| 87 if(icc_buf_ptr == NULL || icc_length == 0) { | 78 if(icc_buf_ptr == NULL || icc_length == 0) { |
| 88 return FALSE; | 79 return FALSE; |
| 89 } | 80 } |
| 90 FX_DWORD icc_segment_size = (JPEG_MARKER_MAXSIZE - 2 - JPEG_OVERHEAD_LEN); | 81 FX_DWORD icc_segment_size = (JPEG_MARKER_MAXSIZE - 2 - JPEG_OVERHEAD_LEN); |
| 91 FX_DWORD icc_segment_num = (icc_length / icc_segment_size) + 1; | 82 FX_DWORD icc_segment_num = (icc_length / icc_segment_size) + 1; |
| 92 if (icc_segment_num > 255) { | 83 if (icc_segment_num > 255) { |
| 93 return FALSE; | 84 return FALSE; |
| 94 } | 85 } |
| (...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 673 return m_pExtProvider->GetAvailInput(pContext, avail_buf_ptr); | 664 return m_pExtProvider->GetAvailInput(pContext, avail_buf_ptr); |
| 674 } | 665 } |
| 675 if(avail_buf_ptr != NULL) { | 666 if(avail_buf_ptr != NULL) { |
| 676 *avail_buf_ptr = NULL; | 667 *avail_buf_ptr = NULL; |
| 677 if(((FXJPEG_Context*)pContext)->m_SrcMgr.bytes_in_buffer > 0) { | 668 if(((FXJPEG_Context*)pContext)->m_SrcMgr.bytes_in_buffer > 0) { |
| 678 *avail_buf_ptr = (FX_LPBYTE)((FXJPEG_Context*)pContext)->m_SrcMgr.ne
xt_input_byte; | 669 *avail_buf_ptr = (FX_LPBYTE)((FXJPEG_Context*)pContext)->m_SrcMgr.ne
xt_input_byte; |
| 679 } | 670 } |
| 680 } | 671 } |
| 681 return (FX_DWORD)((FXJPEG_Context*)pContext)->m_SrcMgr.bytes_in_buffer; | 672 return (FX_DWORD)((FXJPEG_Context*)pContext)->m_SrcMgr.bytes_in_buffer; |
| 682 } | 673 } |
| OLD | NEW |