Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(632)

Side by Side Diff: core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp

Issue 1666663004: Add unit tests for ascii85 and hex decoders. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: fix Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | core/src/fpdfapi/fpdf_parser/fpdf_parser_decode_embeddertest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 8
9 #include "core/include/fpdfapi/fpdf_module.h" 9 #include "core/include/fpdfapi/fpdf_module.h"
10 #include "core/include/fpdfapi/fpdf_parser.h" 10 #include "core/include/fpdfapi/fpdf_parser.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 0x00ea, 0x00eb, 0x00ec, 0x00ed, 0x00ee, 0x00ef, 0x00f0, 0x00f1, 0x00f2, 43 0x00ea, 0x00eb, 0x00ec, 0x00ed, 0x00ee, 0x00ef, 0x00f0, 0x00f1, 0x00f2,
44 0x00f3, 0x00f4, 0x00f5, 0x00f6, 0x00f7, 0x00f8, 0x00f9, 0x00fa, 0x00fb, 44 0x00f3, 0x00f4, 0x00f5, 0x00f6, 0x00f7, 0x00f8, 0x00f9, 0x00fa, 0x00fb,
45 0x00fc, 0x00fd, 0x00fe, 0x00ff}; 45 0x00fc, 0x00fd, 0x00fe, 0x00ff};
46 46
47 FX_DWORD A85Decode(const uint8_t* src_buf, 47 FX_DWORD A85Decode(const uint8_t* src_buf,
48 FX_DWORD src_size, 48 FX_DWORD src_size,
49 uint8_t*& dest_buf, 49 uint8_t*& dest_buf,
50 FX_DWORD& dest_size) { 50 FX_DWORD& dest_size) {
51 dest_size = 0; 51 dest_size = 0;
52 dest_buf = nullptr; 52 dest_buf = nullptr;
53 if (src_size == 0) { 53 if (src_size == 0)
54 return 0; 54 return 0;
55 } 55
56 // Count legal characters and zeros.
56 FX_DWORD zcount = 0; 57 FX_DWORD zcount = 0;
57 FX_DWORD pos = 0; 58 FX_DWORD pos = 0;
58 while (pos < src_size) { 59 while (pos < src_size) {
59 uint8_t ch = src_buf[pos]; 60 uint8_t ch = src_buf[pos];
60 if (ch < '!' && ch != '\n' && ch != '\r' && ch != ' ' && ch != '\t') {
61 break;
62 }
63 if (ch == 'z') { 61 if (ch == 'z') {
64 zcount++; 62 zcount++;
65 } else if (ch > 'u') { 63 } else if ((ch < '!' || ch > 'u') && !PDFCharIsLineEnding(ch) &&
64 ch != ' ' && ch != '\t') {
66 break; 65 break;
67 } 66 }
68 pos++; 67 pos++;
69 } 68 }
70 if (pos == 0) { 69 // No content to decode.
70 if (pos == 0)
71 return 0; 71 return 0;
72 } 72
73 if (zcount > UINT_MAX / 4) { 73 // Count the space needed to contain non-zero characters. The encoding ratio
74 // of Ascii85 is 4:5.
75 FX_DWORD space_for_non_zeroes = (pos - zcount) / 5 * 4 + 4;
76 if (zcount > (UINT_MAX - space_for_non_zeroes) / 4) {
74 return (FX_DWORD)-1; 77 return (FX_DWORD)-1;
75 } 78 }
76 if (zcount * 4 > UINT_MAX - (pos - zcount)) { 79 dest_buf = FX_Alloc(uint8_t, zcount * 4 + space_for_non_zeroes);
77 return (FX_DWORD)-1; 80 size_t state = 0;
78 }
79 dest_buf = FX_Alloc(uint8_t, zcount * 4 + (pos - zcount));
80 int state = 0;
81 uint32_t res = 0; 81 uint32_t res = 0;
82 pos = dest_size = 0; 82 pos = dest_size = 0;
83 while (pos < src_size) { 83 while (pos < src_size) {
84 uint8_t ch = src_buf[pos++]; 84 uint8_t ch = src_buf[pos++];
85 if (PDFCharIsLineEnding(ch) || ch == ' ' || ch == '\t') 85 if (PDFCharIsLineEnding(ch) || ch == ' ' || ch == '\t')
86 continue; 86 continue;
87 87
88 if (ch == 'z') { 88 if (ch == 'z') {
89 FXSYS_memset(dest_buf + dest_size, 0, 4); 89 FXSYS_memset(dest_buf + dest_size, 0, 4);
90 state = 0; 90 state = 0;
91 res = 0; 91 res = 0;
92 dest_size += 4; 92 dest_size += 4;
93 } else { 93 } else if (ch >= '!' && ch <= 'u') {
94 if (ch < '!' || ch > 'u') {
95 break;
96 }
97 res = res * 85 + ch - 33; 94 res = res * 85 + ch - 33;
98 state++; 95 state++;
99 if (state == 5) { 96 if (state == 5) {
100 for (int i = 0; i < 4; i++) { 97 for (size_t i = 0; i < 4; i++) {
101 dest_buf[dest_size++] = (uint8_t)(res >> (3 - i) * 8); 98 dest_buf[dest_size++] = (uint8_t)(res >> (3 - i) * 8);
102 } 99 }
103 state = 0; 100 state = 0;
104 res = 0; 101 res = 0;
105 } 102 }
103 } else {
104 // The end or illegal character.
105 break;
106 } 106 }
107 } 107 }
108 // Handle partial group.
108 if (state) { 109 if (state) {
109 int i; 110 for (size_t i = state; i < 5; i++)
110 for (i = state; i < 5; i++) {
111 res = res * 85 + 84; 111 res = res * 85 + 84;
112 } 112 for (size_t i = 0; i < state - 1; i++)
113 for (i = 0; i < state - 1; i++) {
114 dest_buf[dest_size++] = (uint8_t)(res >> (3 - i) * 8); 113 dest_buf[dest_size++] = (uint8_t)(res >> (3 - i) * 8);
115 }
116 } 114 }
117 if (pos < src_size && src_buf[pos] == '>') { 115 if (pos < src_size && src_buf[pos] == '>')
118 pos++; 116 pos++;
119 }
120 return pos; 117 return pos;
121 } 118 }
119
122 FX_DWORD HexDecode(const uint8_t* src_buf, 120 FX_DWORD HexDecode(const uint8_t* src_buf,
123 FX_DWORD src_size, 121 FX_DWORD src_size,
124 uint8_t*& dest_buf, 122 uint8_t*& dest_buf,
125 FX_DWORD& dest_size) { 123 FX_DWORD& dest_size) {
126 FX_DWORD i; 124 dest_size = 0;
127 for (i = 0; i < src_size; i++) 125 if (src_size == 0) {
128 if (src_buf[i] == '>') { 126 dest_buf = nullptr;
129 break; 127 return 0;
130 } 128 }
129
130 FX_DWORD i = 0;
131 // Find the end of data.
132 while (i < src_size && src_buf[i] != '>')
133 i++;
134
131 dest_buf = FX_Alloc(uint8_t, i / 2 + 1); 135 dest_buf = FX_Alloc(uint8_t, i / 2 + 1);
132 dest_size = 0;
133 bool bFirst = true; 136 bool bFirst = true;
134 for (i = 0; i < src_size; i++) { 137 for (i = 0; i < src_size; i++) {
135 uint8_t ch = src_buf[i]; 138 uint8_t ch = src_buf[i];
136 if (PDFCharIsLineEnding(ch) || ch == ' ' || ch == '\t') 139 if (PDFCharIsLineEnding(ch) || ch == ' ' || ch == '\t')
137 continue; 140 continue;
138 141
139 if (ch == '>') { 142 if (ch == '>') {
140 ++i; 143 ++i;
141 break; 144 break;
142 } 145 }
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 } else { 214 } else {
212 break; 215 break;
213 } 216 }
214 } 217 }
215 FX_DWORD ret = i + 1; 218 FX_DWORD ret = i + 1;
216 if (ret > src_size) { 219 if (ret > src_size) {
217 ret = src_size; 220 ret = src_size;
218 } 221 }
219 return ret; 222 return ret;
220 } 223 }
224
221 ICodec_ScanlineDecoder* FPDFAPI_CreateFaxDecoder( 225 ICodec_ScanlineDecoder* FPDFAPI_CreateFaxDecoder(
222 const uint8_t* src_buf, 226 const uint8_t* src_buf,
223 FX_DWORD src_size, 227 FX_DWORD src_size,
224 int width, 228 int width,
225 int height, 229 int height,
226 const CPDF_Dictionary* pParams) { 230 const CPDF_Dictionary* pParams) {
227 int K = 0; 231 int K = 0;
228 FX_BOOL EndOfLine = FALSE; 232 FX_BOOL EndOfLine = FALSE;
229 FX_BOOL ByteAlign = FALSE; 233 FX_BOOL ByteAlign = FALSE;
230 FX_BOOL BlackIs1 = FALSE; 234 FX_BOOL BlackIs1 = FALSE;
(...skipping 10 matching lines...) Expand all
241 Rows = 0; 245 Rows = 0;
242 } 246 }
243 if (Columns <= 0 || Rows < 0 || Columns > USHRT_MAX || Rows > USHRT_MAX) { 247 if (Columns <= 0 || Rows < 0 || Columns > USHRT_MAX || Rows > USHRT_MAX) {
244 return nullptr; 248 return nullptr;
245 } 249 }
246 } 250 }
247 return CPDF_ModuleMgr::Get()->GetFaxModule()->CreateDecoder( 251 return CPDF_ModuleMgr::Get()->GetFaxModule()->CreateDecoder(
248 src_buf, src_size, width, height, K, EndOfLine, ByteAlign, BlackIs1, 252 src_buf, src_size, width, height, K, EndOfLine, ByteAlign, BlackIs1,
249 Columns, Rows); 253 Columns, Rows);
250 } 254 }
255
251 static FX_BOOL CheckFlateDecodeParams(int Colors, 256 static FX_BOOL CheckFlateDecodeParams(int Colors,
252 int BitsPerComponent, 257 int BitsPerComponent,
253 int Columns) { 258 int Columns) {
254 if (Columns < 0) { 259 if (Columns < 0) {
255 return FALSE; 260 return FALSE;
256 } 261 }
257 int check = Columns; 262 int check = Columns;
258 if (Colors < 0 || (check > 0 && Colors > INT_MAX / check)) { 263 if (Colors < 0 || (check > 0 && Colors > INT_MAX / check)) {
259 return FALSE; 264 return FALSE;
260 } 265 }
261 check *= Colors; 266 check *= Colors;
262 if (BitsPerComponent < 0 || 267 if (BitsPerComponent < 0 ||
263 (check > 0 && BitsPerComponent > INT_MAX / check)) { 268 (check > 0 && BitsPerComponent > INT_MAX / check)) {
264 return FALSE; 269 return FALSE;
265 } 270 }
266 check *= BitsPerComponent; 271 check *= BitsPerComponent;
267 if (check > INT_MAX - 7) { 272 if (check > INT_MAX - 7) {
268 return FALSE; 273 return FALSE;
269 } 274 }
270 return TRUE; 275 return TRUE;
271 } 276 }
277
272 ICodec_ScanlineDecoder* FPDFAPI_CreateFlateDecoder( 278 ICodec_ScanlineDecoder* FPDFAPI_CreateFlateDecoder(
273 const uint8_t* src_buf, 279 const uint8_t* src_buf,
274 FX_DWORD src_size, 280 FX_DWORD src_size,
275 int width, 281 int width,
276 int height, 282 int height,
277 int nComps, 283 int nComps,
278 int bpc, 284 int bpc,
279 const CPDF_Dictionary* pParams) { 285 const CPDF_Dictionary* pParams) {
280 int predictor = 0; 286 int predictor = 0;
281 int Colors = 0, BitsPerComponent = 0, Columns = 0; 287 int Colors = 0, BitsPerComponent = 0, Columns = 0;
282 if (pParams) { 288 if (pParams) {
283 predictor = pParams->GetIntegerBy("Predictor"); 289 predictor = pParams->GetIntegerBy("Predictor");
284 Colors = pParams->GetIntegerBy("Colors", 1); 290 Colors = pParams->GetIntegerBy("Colors", 1);
285 BitsPerComponent = pParams->GetIntegerBy("BitsPerComponent", 8); 291 BitsPerComponent = pParams->GetIntegerBy("BitsPerComponent", 8);
286 Columns = pParams->GetIntegerBy("Columns", 1); 292 Columns = pParams->GetIntegerBy("Columns", 1);
287 if (!CheckFlateDecodeParams(Colors, BitsPerComponent, Columns)) { 293 if (!CheckFlateDecodeParams(Colors, BitsPerComponent, Columns)) {
288 return nullptr; 294 return nullptr;
289 } 295 }
290 } 296 }
291 return CPDF_ModuleMgr::Get()->GetFlateModule()->CreateDecoder( 297 return CPDF_ModuleMgr::Get()->GetFlateModule()->CreateDecoder(
292 src_buf, src_size, width, height, nComps, bpc, predictor, Colors, 298 src_buf, src_size, width, height, nComps, bpc, predictor, Colors,
293 BitsPerComponent, Columns); 299 BitsPerComponent, Columns);
294 } 300 }
301
295 FX_DWORD FPDFAPI_FlateOrLZWDecode(FX_BOOL bLZW, 302 FX_DWORD FPDFAPI_FlateOrLZWDecode(FX_BOOL bLZW,
296 const uint8_t* src_buf, 303 const uint8_t* src_buf,
297 FX_DWORD src_size, 304 FX_DWORD src_size,
298 CPDF_Dictionary* pParams, 305 CPDF_Dictionary* pParams,
299 FX_DWORD estimated_size, 306 FX_DWORD estimated_size,
300 uint8_t*& dest_buf, 307 uint8_t*& dest_buf,
301 FX_DWORD& dest_size) { 308 FX_DWORD& dest_size) {
302 int predictor = 0; 309 int predictor = 0;
303 FX_BOOL bEarlyChange = TRUE; 310 FX_BOOL bEarlyChange = TRUE;
304 int Colors = 0, BitsPerComponent = 0, Columns = 0; 311 int Colors = 0, BitsPerComponent = 0, Columns = 0;
305 if (pParams) { 312 if (pParams) {
306 predictor = pParams->GetIntegerBy("Predictor"); 313 predictor = pParams->GetIntegerBy("Predictor");
307 bEarlyChange = pParams->GetIntegerBy("EarlyChange", 1); 314 bEarlyChange = pParams->GetIntegerBy("EarlyChange", 1);
308 Colors = pParams->GetIntegerBy("Colors", 1); 315 Colors = pParams->GetIntegerBy("Colors", 1);
309 BitsPerComponent = pParams->GetIntegerBy("BitsPerComponent", 8); 316 BitsPerComponent = pParams->GetIntegerBy("BitsPerComponent", 8);
310 Columns = pParams->GetIntegerBy("Columns", 1); 317 Columns = pParams->GetIntegerBy("Columns", 1);
311 if (!CheckFlateDecodeParams(Colors, BitsPerComponent, Columns)) { 318 if (!CheckFlateDecodeParams(Colors, BitsPerComponent, Columns)) {
312 return (FX_DWORD)-1; 319 return (FX_DWORD)-1;
313 } 320 }
314 } 321 }
315 return CPDF_ModuleMgr::Get()->GetFlateModule()->FlateOrLZWDecode( 322 return CPDF_ModuleMgr::Get()->GetFlateModule()->FlateOrLZWDecode(
316 bLZW, src_buf, src_size, bEarlyChange, predictor, Colors, 323 bLZW, src_buf, src_size, bEarlyChange, predictor, Colors,
317 BitsPerComponent, Columns, estimated_size, dest_buf, dest_size); 324 BitsPerComponent, Columns, estimated_size, dest_buf, dest_size);
318 } 325 }
326
319 FX_BOOL PDF_DataDecode(const uint8_t* src_buf, 327 FX_BOOL PDF_DataDecode(const uint8_t* src_buf,
320 FX_DWORD src_size, 328 FX_DWORD src_size,
321 const CPDF_Dictionary* pDict, 329 const CPDF_Dictionary* pDict,
322 uint8_t*& dest_buf, 330 uint8_t*& dest_buf,
323 FX_DWORD& dest_size, 331 FX_DWORD& dest_size,
324 CFX_ByteString& ImageEncoding, 332 CFX_ByteString& ImageEncoding,
325 CPDF_Dictionary*& pImageParms, 333 CPDF_Dictionary*& pImageParms,
326 FX_DWORD last_estimated_size, 334 FX_DWORD last_estimated_size,
327 FX_BOOL bImageAcc) { 335 FX_BOOL bImageAcc) {
328 CPDF_Object* pDecoder = pDict ? pDict->GetElementValue("Filter") : nullptr; 336 CPDF_Object* pDecoder = pDict ? pDict->GetElementValue("Filter") : nullptr;
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 } 418 }
411 last_buf = new_buf; 419 last_buf = new_buf;
412 last_size = new_size; 420 last_size = new_size;
413 } 421 }
414 ImageEncoding = ""; 422 ImageEncoding = "";
415 pImageParms = nullptr; 423 pImageParms = nullptr;
416 dest_buf = last_buf; 424 dest_buf = last_buf;
417 dest_size = last_size; 425 dest_size = last_size;
418 return TRUE; 426 return TRUE;
419 } 427 }
428
420 CFX_WideString PDF_DecodeText(const uint8_t* src_data, 429 CFX_WideString PDF_DecodeText(const uint8_t* src_data,
421 FX_DWORD src_len, 430 FX_DWORD src_len,
422 CFX_CharMap* pCharMap) { 431 CFX_CharMap* pCharMap) {
423 CFX_WideString result; 432 CFX_WideString result;
424 if (src_len >= 2 && ((src_data[0] == 0xfe && src_data[1] == 0xff) || 433 if (src_len >= 2 && ((src_data[0] == 0xfe && src_data[1] == 0xff) ||
425 (src_data[0] == 0xff && src_data[1] == 0xfe))) { 434 (src_data[0] == 0xff && src_data[1] == 0xfe))) {
426 FX_BOOL bBE = src_data[0] == 0xfe; 435 FX_BOOL bBE = src_data[0] == 0xfe;
427 FX_DWORD max_chars = (src_len - 2) / 2; 436 FX_DWORD max_chars = (src_len - 2) / 2;
428 if (!max_chars) { 437 if (!max_chars) {
429 return result; 438 return result;
(...skipping 27 matching lines...) Expand all
457 for (FX_DWORD i = 0; i < src_len; i++) { 466 for (FX_DWORD i = 0; i < src_len; i++) {
458 dest_buf[i] = PDFDocEncoding[src_data[i]]; 467 dest_buf[i] = PDFDocEncoding[src_data[i]];
459 } 468 }
460 result.ReleaseBuffer(src_len); 469 result.ReleaseBuffer(src_len);
461 } else { 470 } else {
462 return (*pCharMap->m_GetWideString)( 471 return (*pCharMap->m_GetWideString)(
463 pCharMap, CFX_ByteString((const FX_CHAR*)src_data, src_len)); 472 pCharMap, CFX_ByteString((const FX_CHAR*)src_data, src_len));
464 } 473 }
465 return result; 474 return result;
466 } 475 }
476
467 CFX_ByteString PDF_EncodeText(const FX_WCHAR* pString, 477 CFX_ByteString PDF_EncodeText(const FX_WCHAR* pString,
468 int len, 478 int len,
469 CFX_CharMap* pCharMap) { 479 CFX_CharMap* pCharMap) {
470 if (len == -1) { 480 if (len == -1) {
471 len = FXSYS_wcslen(pString); 481 len = FXSYS_wcslen(pString);
472 } 482 }
473 CFX_ByteString result; 483 CFX_ByteString result;
474 if (!pCharMap) { 484 if (!pCharMap) {
475 FX_CHAR* dest_buf1 = result.GetBuffer(len); 485 FX_CHAR* dest_buf1 = result.GetBuffer(len);
476 int i; 486 int i;
(...skipping 25 matching lines...) Expand all
502 dest_buf2[0] = 0xfe; 512 dest_buf2[0] = 0xfe;
503 dest_buf2[1] = 0xff; 513 dest_buf2[1] = 0xff;
504 dest_buf2 += 2; 514 dest_buf2 += 2;
505 for (int i = 0; i < len; i++) { 515 for (int i = 0; i < len; i++) {
506 *dest_buf2++ = pString[i] >> 8; 516 *dest_buf2++ = pString[i] >> 8;
507 *dest_buf2++ = (uint8_t)pString[i]; 517 *dest_buf2++ = (uint8_t)pString[i];
508 } 518 }
509 result.ReleaseBuffer(encLen); 519 result.ReleaseBuffer(encLen);
510 return result; 520 return result;
511 } 521 }
522
512 CFX_ByteString PDF_EncodeString(const CFX_ByteString& src, FX_BOOL bHex) { 523 CFX_ByteString PDF_EncodeString(const CFX_ByteString& src, FX_BOOL bHex) {
513 CFX_ByteTextBuf result; 524 CFX_ByteTextBuf result;
514 int srclen = src.GetLength(); 525 int srclen = src.GetLength();
515 if (bHex) { 526 if (bHex) {
516 result.AppendChar('<'); 527 result.AppendChar('<');
517 for (int i = 0; i < srclen; i++) { 528 for (int i = 0; i < srclen; i++) {
518 result.AppendChar("0123456789ABCDEF"[src[i] / 16]); 529 result.AppendChar("0123456789ABCDEF"[src[i] / 16]);
519 result.AppendChar("0123456789ABCDEF"[src[i] % 16]); 530 result.AppendChar("0123456789ABCDEF"[src[i] % 16]);
520 } 531 }
521 result.AppendChar('>'); 532 result.AppendChar('>');
522 return result.GetByteString(); 533 return result.GetByteString();
523 } 534 }
524 result.AppendChar('('); 535 result.AppendChar('(');
525 for (int i = 0; i < srclen; i++) { 536 for (int i = 0; i < srclen; i++) {
526 uint8_t ch = src[i]; 537 uint8_t ch = src[i];
527 if (ch == ')' || ch == '\\' || ch == '(') { 538 if (ch == ')' || ch == '\\' || ch == '(') {
528 result.AppendChar('\\'); 539 result.AppendChar('\\');
529 } else if (ch == 0x0a) { 540 } else if (ch == 0x0a) {
530 result << "\\n"; 541 result << "\\n";
531 continue; 542 continue;
532 } else if (ch == 0x0d) { 543 } else if (ch == 0x0d) {
533 result << "\\r"; 544 result << "\\r";
534 continue; 545 continue;
535 } 546 }
536 result.AppendChar(ch); 547 result.AppendChar(ch);
537 } 548 }
538 result.AppendChar(')'); 549 result.AppendChar(')');
539 return result.GetByteString(); 550 return result.GetByteString();
540 } 551 }
552
541 void FlateEncode(const uint8_t* src_buf, 553 void FlateEncode(const uint8_t* src_buf,
542 FX_DWORD src_size, 554 FX_DWORD src_size,
543 uint8_t*& dest_buf, 555 uint8_t*& dest_buf,
544 FX_DWORD& dest_size) { 556 FX_DWORD& dest_size) {
545 CCodec_ModuleMgr* pEncoders = CPDF_ModuleMgr::Get()->GetCodecModule(); 557 CCodec_ModuleMgr* pEncoders = CPDF_ModuleMgr::Get()->GetCodecModule();
546 if (pEncoders) { 558 if (pEncoders) {
547 pEncoders->GetFlateModule()->Encode(src_buf, src_size, dest_buf, dest_size); 559 pEncoders->GetFlateModule()->Encode(src_buf, src_size, dest_buf, dest_size);
548 } 560 }
549 } 561 }
562
550 void FlateEncode(const uint8_t* src_buf, 563 void FlateEncode(const uint8_t* src_buf,
551 FX_DWORD src_size, 564 FX_DWORD src_size,
552 int predictor, 565 int predictor,
553 int Colors, 566 int Colors,
554 int BitsPerComponent, 567 int BitsPerComponent,
555 int Columns, 568 int Columns,
556 uint8_t*& dest_buf, 569 uint8_t*& dest_buf,
557 FX_DWORD& dest_size) { 570 FX_DWORD& dest_size) {
558 CCodec_ModuleMgr* pEncoders = CPDF_ModuleMgr::Get()->GetCodecModule(); 571 CCodec_ModuleMgr* pEncoders = CPDF_ModuleMgr::Get()->GetCodecModule();
559 if (pEncoders) { 572 if (pEncoders) {
560 pEncoders->GetFlateModule()->Encode(src_buf, src_size, predictor, Colors, 573 pEncoders->GetFlateModule()->Encode(src_buf, src_size, predictor, Colors,
561 BitsPerComponent, Columns, dest_buf, 574 BitsPerComponent, Columns, dest_buf,
562 dest_size); 575 dest_size);
563 } 576 }
564 } 577 }
578
565 FX_DWORD FlateDecode(const uint8_t* src_buf, 579 FX_DWORD FlateDecode(const uint8_t* src_buf,
566 FX_DWORD src_size, 580 FX_DWORD src_size,
567 uint8_t*& dest_buf, 581 uint8_t*& dest_buf,
568 FX_DWORD& dest_size) { 582 FX_DWORD& dest_size) {
569 CCodec_ModuleMgr* pEncoders = CPDF_ModuleMgr::Get()->GetCodecModule(); 583 CCodec_ModuleMgr* pEncoders = CPDF_ModuleMgr::Get()->GetCodecModule();
570 if (pEncoders) { 584 if (pEncoders) {
571 return pEncoders->GetFlateModule()->FlateOrLZWDecode( 585 return pEncoders->GetFlateModule()->FlateOrLZWDecode(
572 FALSE, src_buf, src_size, FALSE, 0, 0, 0, 0, 0, dest_buf, dest_size); 586 FALSE, src_buf, src_size, FALSE, 0, 0, 0, 0, 0, dest_buf, dest_size);
573 } 587 }
574 return 0; 588 return 0;
575 } 589 }
OLDNEW
« no previous file with comments | « no previous file | core/src/fpdfapi/fpdf_parser/fpdf_parser_decode_embeddertest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698