2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-06-01 01:40:51 +00:00

In Pl_TIFFPredictor avoid repeated calls to getNext

This commit is contained in:
m-holger 2024-01-22 00:32:15 +00:00
parent 73dec35209
commit 2e8b5f290c
2 changed files with 5 additions and 3 deletions

View File

@ -19,7 +19,8 @@ Pl_TIFFPredictor::Pl_TIFFPredictor(
action(action), action(action),
columns(columns), columns(columns),
samples_per_pixel(samples_per_pixel), samples_per_pixel(samples_per_pixel),
bits_per_sample(bits_per_sample) bits_per_sample(bits_per_sample),
p_next(getNext())
{ {
if (samples_per_pixel < 1) { if (samples_per_pixel < 1) {
throw std::runtime_error("TIFFPredictor created with invalid samples_per_pixel"); throw std::runtime_error("TIFFPredictor created with invalid samples_per_pixel");
@ -58,7 +59,7 @@ void
Pl_TIFFPredictor::processRow() 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(p_next);
BitStream in(this->cur_row.data(), 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) {
@ -92,5 +93,5 @@ Pl_TIFFPredictor::finish()
processRow(); processRow();
} }
cur_row.clear(); cur_row.clear();
getNext()->finish(); p_next->finish();
} }

View File

@ -34,6 +34,7 @@ class Pl_TIFFPredictor: public Pipeline
unsigned int samples_per_pixel; unsigned int samples_per_pixel;
unsigned int bits_per_sample; unsigned int bits_per_sample;
std::vector<unsigned char> cur_row; std::vector<unsigned char> cur_row;
Pipeline* p_next;
}; };
#endif // PL_TIFFPREDICTOR_HH #endif // PL_TIFFPREDICTOR_HH