Commit 902fd6df71e89127fdf82a1a309c9c24927276c7
1 parent
6b80e0f1
Change Pl_TIFFPredictor::cur_row to std::vector<unsigned char>
Showing
2 changed files
with
9 additions
and
8 deletions
libqpdf/Pl_TIFFPredictor.cc
| @@ -35,8 +35,7 @@ Pl_TIFFPredictor::Pl_TIFFPredictor( | @@ -35,8 +35,7 @@ Pl_TIFFPredictor::Pl_TIFFPredictor( | ||
| 35 | throw std::runtime_error("TIFFPredictor created with invalid columns value"); | 35 | throw std::runtime_error("TIFFPredictor created with invalid columns value"); |
| 36 | } | 36 | } |
| 37 | this->bytes_per_row = bpr & UINT_MAX; | 37 | this->bytes_per_row = bpr & UINT_MAX; |
| 38 | - this->cur_row = QUtil::make_shared_array<unsigned char>(this->bytes_per_row); | ||
| 39 | - memset(this->cur_row.get(), 0, this->bytes_per_row); | 38 | + this->cur_row.assign(this->bytes_per_row, 0); |
| 40 | } | 39 | } |
| 41 | 40 | ||
| 42 | void | 41 | void |
| @@ -46,19 +45,19 @@ Pl_TIFFPredictor::write(unsigned char const* data, size_t len) | @@ -46,19 +45,19 @@ Pl_TIFFPredictor::write(unsigned char const* data, size_t len) | ||
| 46 | size_t offset = 0; | 45 | size_t offset = 0; |
| 47 | while (len >= left) { | 46 | while (len >= left) { |
| 48 | // finish off current row | 47 | // finish off current row |
| 49 | - memcpy(this->cur_row.get() + this->pos, data + offset, left); | 48 | + memcpy(this->cur_row.data() + this->pos, data + offset, left); |
| 50 | offset += left; | 49 | offset += left; |
| 51 | len -= left; | 50 | len -= left; |
| 52 | 51 | ||
| 53 | processRow(); | 52 | processRow(); |
| 54 | 53 | ||
| 55 | // Prepare for next row | 54 | // Prepare for next row |
| 56 | - memset(this->cur_row.get(), 0, this->bytes_per_row); | 55 | + this->cur_row.assign(this->bytes_per_row, 0); |
| 57 | left = this->bytes_per_row; | 56 | left = this->bytes_per_row; |
| 58 | this->pos = 0; | 57 | this->pos = 0; |
| 59 | } | 58 | } |
| 60 | if (len) { | 59 | if (len) { |
| 61 | - memcpy(this->cur_row.get() + this->pos, data + offset, len); | 60 | + memcpy(this->cur_row.data() + this->pos, data + offset, len); |
| 62 | } | 61 | } |
| 63 | this->pos += len; | 62 | this->pos += len; |
| 64 | } | 63 | } |
| @@ -68,7 +67,7 @@ Pl_TIFFPredictor::processRow() | @@ -68,7 +67,7 @@ Pl_TIFFPredictor::processRow() | ||
| 68 | { | 67 | { |
| 69 | QTC::TC("libtests", "Pl_TIFFPredictor processRow", (action == a_decode ? 0 : 1)); | 68 | QTC::TC("libtests", "Pl_TIFFPredictor processRow", (action == a_decode ? 0 : 1)); |
| 70 | BitWriter bw(this->getNext()); | 69 | BitWriter bw(this->getNext()); |
| 71 | - BitStream in(this->cur_row.get(), this->bytes_per_row); | 70 | + BitStream in(this->cur_row.data(), this->bytes_per_row); |
| 72 | std::vector<long long> prev; | 71 | std::vector<long long> prev; |
| 73 | for (unsigned int i = 0; i < this->samples_per_pixel; ++i) { | 72 | for (unsigned int i = 0; i < this->samples_per_pixel; ++i) { |
| 74 | long long sample = in.getBitsSigned(this->bits_per_sample); | 73 | long long sample = in.getBitsSigned(this->bits_per_sample); |
| @@ -100,6 +99,6 @@ Pl_TIFFPredictor::finish() | @@ -100,6 +99,6 @@ Pl_TIFFPredictor::finish() | ||
| 100 | processRow(); | 99 | processRow(); |
| 101 | } | 100 | } |
| 102 | this->pos = 0; | 101 | this->pos = 0; |
| 103 | - memset(this->cur_row.get(), 0, this->bytes_per_row); | 102 | + this->cur_row.assign(this->bytes_per_row, 0); |
| 104 | getNext()->finish(); | 103 | getNext()->finish(); |
| 105 | } | 104 | } |
libqpdf/qpdf/Pl_TIFFPredictor.hh
| @@ -6,6 +6,8 @@ | @@ -6,6 +6,8 @@ | ||
| 6 | 6 | ||
| 7 | #include <qpdf/Pipeline.hh> | 7 | #include <qpdf/Pipeline.hh> |
| 8 | 8 | ||
| 9 | +#include<vector> | ||
| 10 | + | ||
| 9 | class Pl_TIFFPredictor: public Pipeline | 11 | class Pl_TIFFPredictor: public Pipeline |
| 10 | { | 12 | { |
| 11 | public: | 13 | public: |
| @@ -31,7 +33,7 @@ class Pl_TIFFPredictor: public Pipeline | @@ -31,7 +33,7 @@ class Pl_TIFFPredictor: public Pipeline | ||
| 31 | unsigned int bytes_per_row; | 33 | unsigned int bytes_per_row; |
| 32 | unsigned int samples_per_pixel; | 34 | unsigned int samples_per_pixel; |
| 33 | unsigned int bits_per_sample; | 35 | unsigned int bits_per_sample; |
| 34 | - std::shared_ptr<unsigned char> cur_row; | 36 | + std::vector<unsigned char> cur_row; |
| 35 | size_t pos; | 37 | size_t pos; |
| 36 | }; | 38 | }; |
| 37 | 39 |