| 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 <limits.h> | 7 #include <limits.h> |
| 8 #include "../../../include/fpdfapi/fpdf_parser.h" | 8 #include "../../../include/fpdfapi/fpdf_parser.h" |
| 9 #include "../../../include/fpdfapi/fpdf_module.h" | 9 #include "../../../include/fpdfapi/fpdf_module.h" |
| 10 #include "../../../include/fxcodec/fx_codec.h" | 10 #include "../../../include/fxcodec/fx_codec.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 0x00b4, 0x00b5, 0x00b6, 0x00b7, 0x00b8, 0x00b9, 0x00ba, 0x00bb, 0x00bc, | 35 0x00b4, 0x00b5, 0x00b6, 0x00b7, 0x00b8, 0x00b9, 0x00ba, 0x00bb, 0x00bc, |
| 36 0x00bd, 0x00be, 0x00bf, 0x00c0, 0x00c1, 0x00c2, 0x00c3, 0x00c4, 0x00c5, | 36 0x00bd, 0x00be, 0x00bf, 0x00c0, 0x00c1, 0x00c2, 0x00c3, 0x00c4, 0x00c5, |
| 37 0x00c6, 0x00c7, 0x00c8, 0x00c9, 0x00ca, 0x00cb, 0x00cc, 0x00cd, 0x00ce, | 37 0x00c6, 0x00c7, 0x00c8, 0x00c9, 0x00ca, 0x00cb, 0x00cc, 0x00cd, 0x00ce, |
| 38 0x00cf, 0x00d0, 0x00d1, 0x00d2, 0x00d3, 0x00d4, 0x00d5, 0x00d6, 0x00d7, | 38 0x00cf, 0x00d0, 0x00d1, 0x00d2, 0x00d3, 0x00d4, 0x00d5, 0x00d6, 0x00d7, |
| 39 0x00d8, 0x00d9, 0x00da, 0x00db, 0x00dc, 0x00dd, 0x00de, 0x00df, 0x00e0, | 39 0x00d8, 0x00d9, 0x00da, 0x00db, 0x00dc, 0x00dd, 0x00de, 0x00df, 0x00e0, |
| 40 0x00e1, 0x00e2, 0x00e3, 0x00e4, 0x00e5, 0x00e6, 0x00e7, 0x00e8, 0x00e9, | 40 0x00e1, 0x00e2, 0x00e3, 0x00e4, 0x00e5, 0x00e6, 0x00e7, 0x00e8, 0x00e9, |
| 41 0x00ea, 0x00eb, 0x00ec, 0x00ed, 0x00ee, 0x00ef, 0x00f0, 0x00f1, 0x00f2, | 41 0x00ea, 0x00eb, 0x00ec, 0x00ed, 0x00ee, 0x00ef, 0x00f0, 0x00f1, 0x00f2, |
| 42 0x00f3, 0x00f4, 0x00f5, 0x00f6, 0x00f7, 0x00f8, 0x00f9, 0x00fa, 0x00fb, | 42 0x00f3, 0x00f4, 0x00f5, 0x00f6, 0x00f7, 0x00f8, 0x00f9, 0x00fa, 0x00fb, |
| 43 0x00fc, 0x00fd, 0x00fe, 0x00ff}; | 43 0x00fc, 0x00fd, 0x00fe, 0x00ff}; |
| 44 | 44 |
| 45 FX_DWORD _A85Decode(const uint8_t* src_buf, | 45 FX_DWORD A85Decode(const uint8_t* src_buf, |
| 46 FX_DWORD src_size, | 46 FX_DWORD src_size, |
| 47 uint8_t*& dest_buf, | 47 uint8_t*& dest_buf, |
| 48 FX_DWORD& dest_size) { | 48 FX_DWORD& dest_size) { |
| 49 dest_size = 0; | 49 dest_size = 0; |
| 50 dest_buf = NULL; | 50 dest_buf = NULL; |
| 51 if (src_size == 0) { | 51 if (src_size == 0) { |
| 52 return 0; | 52 return 0; |
| 53 } | 53 } |
| 54 FX_DWORD zcount = 0; | 54 FX_DWORD zcount = 0; |
| 55 FX_DWORD pos = 0; | 55 FX_DWORD pos = 0; |
| 56 while (pos < src_size) { | 56 while (pos < src_size) { |
| 57 uint8_t ch = src_buf[pos]; | 57 uint8_t ch = src_buf[pos]; |
| 58 if (ch < '!' && ch != '\n' && ch != '\r' && ch != ' ' && ch != '\t') { | 58 if (ch < '!' && ch != '\n' && ch != '\r' && ch != ' ' && ch != '\t') { |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 } | 110 } |
| 111 for (i = 0; i < state - 1; i++) { | 111 for (i = 0; i < state - 1; i++) { |
| 112 dest_buf[dest_size++] = (uint8_t)(res >> (3 - i) * 8); | 112 dest_buf[dest_size++] = (uint8_t)(res >> (3 - i) * 8); |
| 113 } | 113 } |
| 114 } | 114 } |
| 115 if (pos < src_size && src_buf[pos] == '>') { | 115 if (pos < src_size && src_buf[pos] == '>') { |
| 116 pos++; | 116 pos++; |
| 117 } | 117 } |
| 118 return pos; | 118 return pos; |
| 119 } | 119 } |
| 120 FX_DWORD _HexDecode(const uint8_t* src_buf, | 120 FX_DWORD HexDecode(const uint8_t* src_buf, |
| 121 FX_DWORD src_size, | 121 FX_DWORD src_size, |
| 122 uint8_t*& dest_buf, | 122 uint8_t*& dest_buf, |
| 123 FX_DWORD& dest_size) { | 123 FX_DWORD& dest_size) { |
| 124 FX_DWORD i; | 124 FX_DWORD i; |
| 125 for (i = 0; i < src_size; i++) | 125 for (i = 0; i < src_size; i++) |
| 126 if (src_buf[i] == '>') { | 126 if (src_buf[i] == '>') { |
| 127 break; | 127 break; |
| 128 } | 128 } |
| 129 dest_buf = FX_Alloc(uint8_t, i / 2 + 1); | 129 dest_buf = FX_Alloc(uint8_t, i / 2 + 1); |
| 130 dest_size = 0; | 130 dest_size = 0; |
| 131 FX_BOOL bFirstDigit = TRUE; | 131 FX_BOOL bFirstDigit = TRUE; |
| 132 for (i = 0; i < src_size; i++) { | 132 for (i = 0; i < src_size; i++) { |
| 133 uint8_t ch = src_buf[i]; | 133 uint8_t ch = src_buf[i]; |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 pImageParms = pParam; | 373 pImageParms = pParam; |
| 374 return TRUE; | 374 return TRUE; |
| 375 } | 375 } |
| 376 offset = FPDFAPI_FlateOrLZWDecode(FALSE, last_buf, last_size, pParam, | 376 offset = FPDFAPI_FlateOrLZWDecode(FALSE, last_buf, last_size, pParam, |
| 377 estimated_size, new_buf, new_size); | 377 estimated_size, new_buf, new_size); |
| 378 } else if (decoder == FX_BSTRC("LZWDecode") || decoder == FX_BSTRC("LZW")) { | 378 } else if (decoder == FX_BSTRC("LZWDecode") || decoder == FX_BSTRC("LZW")) { |
| 379 offset = FPDFAPI_FlateOrLZWDecode(TRUE, last_buf, last_size, pParam, | 379 offset = FPDFAPI_FlateOrLZWDecode(TRUE, last_buf, last_size, pParam, |
| 380 estimated_size, new_buf, new_size); | 380 estimated_size, new_buf, new_size); |
| 381 } else if (decoder == FX_BSTRC("ASCII85Decode") || | 381 } else if (decoder == FX_BSTRC("ASCII85Decode") || |
| 382 decoder == FX_BSTRC("A85")) { | 382 decoder == FX_BSTRC("A85")) { |
| 383 offset = _A85Decode(last_buf, last_size, new_buf, new_size); | 383 offset = A85Decode(last_buf, last_size, new_buf, new_size); |
| 384 } else if (decoder == FX_BSTRC("ASCIIHexDecode") || | 384 } else if (decoder == FX_BSTRC("ASCIIHexDecode") || |
| 385 decoder == FX_BSTRC("AHx")) { | 385 decoder == FX_BSTRC("AHx")) { |
| 386 offset = _HexDecode(last_buf, last_size, new_buf, new_size); | 386 offset = HexDecode(last_buf, last_size, new_buf, new_size); |
| 387 } else if (decoder == FX_BSTRC("RunLengthDecode") || | 387 } else if (decoder == FX_BSTRC("RunLengthDecode") || |
| 388 decoder == FX_BSTRC("RL")) { | 388 decoder == FX_BSTRC("RL")) { |
| 389 if (bImageAcc && i == DecoderList.GetSize() - 1) { | 389 if (bImageAcc && i == DecoderList.GetSize() - 1) { |
| 390 ImageEncoding = FX_BSTRC("RunLengthDecode"); | 390 ImageEncoding = FX_BSTRC("RunLengthDecode"); |
| 391 dest_buf = (uint8_t*)last_buf; | 391 dest_buf = (uint8_t*)last_buf; |
| 392 dest_size = last_size; | 392 dest_size = last_size; |
| 393 pImageParms = pParam; | 393 pImageParms = pParam; |
| 394 return TRUE; | 394 return TRUE; |
| 395 } | 395 } |
| 396 offset = RunLengthDecode(last_buf, last_size, new_buf, new_size); | 396 offset = RunLengthDecode(last_buf, last_size, new_buf, new_size); |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 573 FX_DWORD src_size, | 573 FX_DWORD src_size, |
| 574 uint8_t*& dest_buf, | 574 uint8_t*& dest_buf, |
| 575 FX_DWORD& dest_size) { | 575 FX_DWORD& dest_size) { |
| 576 CCodec_ModuleMgr* pEncoders = CPDF_ModuleMgr::Get()->GetCodecModule(); | 576 CCodec_ModuleMgr* pEncoders = CPDF_ModuleMgr::Get()->GetCodecModule(); |
| 577 if (pEncoders) { | 577 if (pEncoders) { |
| 578 return pEncoders->GetFlateModule()->FlateOrLZWDecode( | 578 return pEncoders->GetFlateModule()->FlateOrLZWDecode( |
| 579 FALSE, src_buf, src_size, FALSE, 0, 0, 0, 0, 0, dest_buf, dest_size); | 579 FALSE, src_buf, src_size, FALSE, 0, 0, 0, 0, 0, dest_buf, dest_size); |
| 580 } | 580 } |
| 581 return 0; | 581 return 0; |
| 582 } | 582 } |
| OLD | NEW |