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

Side by Side Diff: core/fxcodec/codec/fx_codec_flate.cpp

Issue 1821043003: Remove FX_WORD in favor of uint16_t. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Use stdint.h directly, bitfield minefield. Created 4 years, 9 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 | « core/fpdftext/fpdf_text_int.h ('k') | core/fxcodec/codec/fx_codec_tiff.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 "core/fxcodec/codec/codec_int.h" 7 #include "core/fxcodec/codec/codec_int.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 dest_buf[index] &= ~(mask << ((8 - col - BitsPerComponent))); 523 dest_buf[index] &= ~(mask << ((8 - col - BitsPerComponent)));
524 dest_buf[index] |= cur; 524 dest_buf[index] |= cur;
525 } 525 }
526 } else if (BitsPerComponent == 8) { 526 } else if (BitsPerComponent == 8) {
527 for (int i = row_size - 1; i >= BytesPerPixel; i--) { 527 for (int i = row_size - 1; i >= BytesPerPixel; i--) {
528 dest_buf[i] -= dest_buf[i - BytesPerPixel]; 528 dest_buf[i] -= dest_buf[i - BytesPerPixel];
529 } 529 }
530 } else { 530 } else {
531 for (int i = row_size - BytesPerPixel; i >= BytesPerPixel; 531 for (int i = row_size - BytesPerPixel; i >= BytesPerPixel;
532 i -= BytesPerPixel) { 532 i -= BytesPerPixel) {
533 FX_WORD pixel = (dest_buf[i] << 8) | dest_buf[i + 1]; 533 uint16_t pixel = (dest_buf[i] << 8) | dest_buf[i + 1];
534 pixel -= 534 pixel -=
535 (dest_buf[i - BytesPerPixel] << 8) | dest_buf[i - BytesPerPixel + 1]; 535 (dest_buf[i - BytesPerPixel] << 8) | dest_buf[i - BytesPerPixel + 1];
536 dest_buf[i] = pixel >> 8; 536 dest_buf[i] = pixel >> 8;
537 dest_buf[i + 1] = (uint8_t)pixel; 537 dest_buf[i + 1] = (uint8_t)pixel;
538 } 538 }
539 } 539 }
540 } 540 }
541 541
542 FX_BOOL TIFF_PredictorEncode(uint8_t*& data_buf, 542 FX_BOOL TIFF_PredictorEncode(uint8_t*& data_buf,
543 FX_DWORD& data_size, 543 FX_DWORD& data_size,
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
580 dest_buf[index] &= ~(1 << (7 - col)); 580 dest_buf[index] &= ~(1 << (7 - col));
581 } 581 }
582 index_pre = index; 582 index_pre = index;
583 col_pre = col; 583 col_pre = col;
584 } 584 }
585 return; 585 return;
586 } 586 }
587 int BytesPerPixel = BitsPerComponent * Colors / 8; 587 int BytesPerPixel = BitsPerComponent * Colors / 8;
588 if (BitsPerComponent == 16) { 588 if (BitsPerComponent == 16) {
589 for (FX_DWORD i = BytesPerPixel; i < row_size; i += 2) { 589 for (FX_DWORD i = BytesPerPixel; i < row_size; i += 2) {
590 FX_WORD pixel = 590 uint16_t pixel =
591 (dest_buf[i - BytesPerPixel] << 8) | dest_buf[i - BytesPerPixel + 1]; 591 (dest_buf[i - BytesPerPixel] << 8) | dest_buf[i - BytesPerPixel + 1];
592 pixel += (dest_buf[i] << 8) | dest_buf[i + 1]; 592 pixel += (dest_buf[i] << 8) | dest_buf[i + 1];
593 dest_buf[i] = pixel >> 8; 593 dest_buf[i] = pixel >> 8;
594 dest_buf[i + 1] = (uint8_t)pixel; 594 dest_buf[i + 1] = (uint8_t)pixel;
595 } 595 }
596 } else { 596 } else {
597 for (FX_DWORD i = BytesPerPixel; i < row_size; i++) { 597 for (FX_DWORD i = BytesPerPixel; i < row_size; i++) {
598 dest_buf[i] += dest_buf[i - BytesPerPixel]; 598 dest_buf[i] += dest_buf[i - BytesPerPixel];
599 } 599 }
600 } 600 }
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
998 FX_DWORD src_size, 998 FX_DWORD src_size,
999 uint8_t*& dest_buf, 999 uint8_t*& dest_buf,
1000 FX_DWORD& dest_size) { 1000 FX_DWORD& dest_size) {
1001 dest_size = src_size + src_size / 1000 + 12; 1001 dest_size = src_size + src_size / 1000 + 12;
1002 dest_buf = FX_Alloc(uint8_t, dest_size); 1002 dest_buf = FX_Alloc(uint8_t, dest_size);
1003 unsigned long temp_size = dest_size; 1003 unsigned long temp_size = dest_size;
1004 FPDFAPI_FlateCompress(dest_buf, &temp_size, src_buf, src_size); 1004 FPDFAPI_FlateCompress(dest_buf, &temp_size, src_buf, src_size);
1005 dest_size = (FX_DWORD)temp_size; 1005 dest_size = (FX_DWORD)temp_size;
1006 return TRUE; 1006 return TRUE;
1007 } 1007 }
OLDNEW
« no previous file with comments | « core/fpdftext/fpdf_text_int.h ('k') | core/fxcodec/codec/fx_codec_tiff.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698