mirror of
https://github.com/qpdf/qpdf.git
synced 2024-06-05 20:00:53 +00:00
Change Pl_TIFFPredictor::cur_row to std::vector<unsigned char>
This commit is contained in:
parent
6b80e0f14b
commit
902fd6df71
|
@ -35,8 +35,7 @@ Pl_TIFFPredictor::Pl_TIFFPredictor(
|
||||||
throw std::runtime_error("TIFFPredictor created with invalid columns value");
|
throw std::runtime_error("TIFFPredictor created with invalid columns value");
|
||||||
}
|
}
|
||||||
this->bytes_per_row = bpr & UINT_MAX;
|
this->bytes_per_row = bpr & UINT_MAX;
|
||||||
this->cur_row = QUtil::make_shared_array<unsigned char>(this->bytes_per_row);
|
this->cur_row.assign(this->bytes_per_row, 0);
|
||||||
memset(this->cur_row.get(), 0, this->bytes_per_row);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -46,19 +45,19 @@ Pl_TIFFPredictor::write(unsigned char const* data, size_t len)
|
||||||
size_t offset = 0;
|
size_t offset = 0;
|
||||||
while (len >= left) {
|
while (len >= left) {
|
||||||
// finish off current row
|
// finish off current row
|
||||||
memcpy(this->cur_row.get() + this->pos, data + offset, left);
|
memcpy(this->cur_row.data() + this->pos, data + offset, left);
|
||||||
offset += left;
|
offset += left;
|
||||||
len -= left;
|
len -= left;
|
||||||
|
|
||||||
processRow();
|
processRow();
|
||||||
|
|
||||||
// Prepare for next row
|
// Prepare for next row
|
||||||
memset(this->cur_row.get(), 0, this->bytes_per_row);
|
this->cur_row.assign(this->bytes_per_row, 0);
|
||||||
left = this->bytes_per_row;
|
left = this->bytes_per_row;
|
||||||
this->pos = 0;
|
this->pos = 0;
|
||||||
}
|
}
|
||||||
if (len) {
|
if (len) {
|
||||||
memcpy(this->cur_row.get() + this->pos, data + offset, len);
|
memcpy(this->cur_row.data() + this->pos, data + offset, len);
|
||||||
}
|
}
|
||||||
this->pos += len;
|
this->pos += len;
|
||||||
}
|
}
|
||||||
|
@ -68,7 +67,7 @@ Pl_TIFFPredictor::processRow()
|
||||||
{
|
{
|
||||||
QTC::TC("libtests", "Pl_TIFFPredictor processRow", (action == a_decode ? 0 : 1));
|
QTC::TC("libtests", "Pl_TIFFPredictor processRow", (action == a_decode ? 0 : 1));
|
||||||
BitWriter bw(this->getNext());
|
BitWriter bw(this->getNext());
|
||||||
BitStream in(this->cur_row.get(), this->bytes_per_row);
|
BitStream in(this->cur_row.data(), this->bytes_per_row);
|
||||||
std::vector<long long> prev;
|
std::vector<long long> prev;
|
||||||
for (unsigned int i = 0; i < this->samples_per_pixel; ++i) {
|
for (unsigned int i = 0; i < this->samples_per_pixel; ++i) {
|
||||||
long long sample = in.getBitsSigned(this->bits_per_sample);
|
long long sample = in.getBitsSigned(this->bits_per_sample);
|
||||||
|
@ -100,6 +99,6 @@ Pl_TIFFPredictor::finish()
|
||||||
processRow();
|
processRow();
|
||||||
}
|
}
|
||||||
this->pos = 0;
|
this->pos = 0;
|
||||||
memset(this->cur_row.get(), 0, this->bytes_per_row);
|
this->cur_row.assign(this->bytes_per_row, 0);
|
||||||
getNext()->finish();
|
getNext()->finish();
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,8 @@
|
||||||
|
|
||||||
#include <qpdf/Pipeline.hh>
|
#include <qpdf/Pipeline.hh>
|
||||||
|
|
||||||
|
#include<vector>
|
||||||
|
|
||||||
class Pl_TIFFPredictor: public Pipeline
|
class Pl_TIFFPredictor: public Pipeline
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -31,7 +33,7 @@ class Pl_TIFFPredictor: public Pipeline
|
||||||
unsigned int bytes_per_row;
|
unsigned int bytes_per_row;
|
||||||
unsigned int samples_per_pixel;
|
unsigned int samples_per_pixel;
|
||||||
unsigned int bits_per_sample;
|
unsigned int bits_per_sample;
|
||||||
std::shared_ptr<unsigned char> cur_row;
|
std::vector<unsigned char> cur_row;
|
||||||
size_t pos;
|
size_t pos;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user