diff options
author | Jay Berkenbilt <ejb@ql.org> | 2022-04-02 23:14:10 +0200 |
---|---|---|
committer | Jay Berkenbilt <ejb@ql.org> | 2022-04-04 14:10:40 +0200 |
commit | 12f1eb15ca3fed6310402847559a7c99d3c77847 (patch) | |
tree | 8935675b623c6f3b4914b8b44f7fa5f2816a9241 /libqpdf/Pl_TIFFPredictor.cc | |
parent | f20fa61eb4c323eb1642c69c236b3d9a1f8b2cdb (diff) | |
download | qpdf-12f1eb15ca3fed6310402847559a7c99d3c77847.tar.zst |
Programmatically apply new formatting to code
Run this:
for i in **/*.cc **/*.c **/*.h **/*.hh; do
clang-format < $i >| $i.new && mv $i.new $i
done
Diffstat (limited to 'libqpdf/Pl_TIFFPredictor.cc')
-rw-r--r-- | libqpdf/Pl_TIFFPredictor.cc | 61 |
1 files changed, 27 insertions, 34 deletions
diff --git a/libqpdf/Pl_TIFFPredictor.cc b/libqpdf/Pl_TIFFPredictor.cc index 7f12a4a1..628e075b 100644 --- a/libqpdf/Pl_TIFFPredictor.cc +++ b/libqpdf/Pl_TIFFPredictor.cc @@ -1,19 +1,22 @@ #include <qpdf/Pl_TIFFPredictor.hh> -#include <qpdf/QTC.hh> #include <qpdf/BitStream.hh> #include <qpdf/BitWriter.hh> +#include <qpdf/QTC.hh> #include <qpdf/QUtil.hh> +#include <limits.h> #include <stdexcept> -#include <vector> #include <string.h> -#include <limits.h> +#include <vector> -Pl_TIFFPredictor::Pl_TIFFPredictor(char const* identifier, Pipeline* next, - action_e action, unsigned int columns, - unsigned int samples_per_pixel, - unsigned int bits_per_sample) : +Pl_TIFFPredictor::Pl_TIFFPredictor( + char const* identifier, + Pipeline* next, + action_e action, + unsigned int columns, + unsigned int samples_per_pixel, + unsigned int bits_per_sample) : Pipeline(identifier, next), action(action), columns(columns), @@ -21,27 +24,24 @@ Pl_TIFFPredictor::Pl_TIFFPredictor(char const* identifier, Pipeline* next, bits_per_sample(bits_per_sample), pos(0) { - if (samples_per_pixel < 1) - { + if (samples_per_pixel < 1) { throw std::runtime_error( "TIFFPredictor created with invalid samples_per_pixel"); } if ((bits_per_sample < 1) || - (bits_per_sample > (8 * (sizeof(unsigned long long))))) - { + (bits_per_sample > (8 * (sizeof(unsigned long long))))) { throw std::runtime_error( "TIFFPredictor created with invalid bits_per_sample"); } unsigned long long bpr = ((columns * bits_per_sample * samples_per_pixel) + 7) / 8; - if ((bpr == 0) || (bpr > (UINT_MAX - 1))) - { + if ((bpr == 0) || (bpr > (UINT_MAX - 1))) { throw std::runtime_error( "TIFFPredictor created with invalid columns value"); } this->bytes_per_row = bpr & UINT_MAX; - this->cur_row = make_array_pointer_holder<unsigned char>( - this->bytes_per_row); + this->cur_row = + make_array_pointer_holder<unsigned char>(this->bytes_per_row); memset(this->cur_row.get(), 0, this->bytes_per_row); } @@ -54,8 +54,7 @@ Pl_TIFFPredictor::write(unsigned char* data, size_t len) { size_t left = this->bytes_per_row - this->pos; size_t offset = 0; - while (len >= left) - { + while (len >= left) { // finish off current row memcpy(this->cur_row.get() + this->pos, data + offset, left); offset += left; @@ -68,8 +67,7 @@ Pl_TIFFPredictor::write(unsigned char* data, size_t len) left = this->bytes_per_row; this->pos = 0; } - if (len) - { + if (len) { memcpy(this->cur_row.get() + this->pos, data + offset, len); } this->pos += len; @@ -78,30 +76,26 @@ Pl_TIFFPredictor::write(unsigned char* data, size_t len) void 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()); BitStream in(this->cur_row.get(), this->bytes_per_row); 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); bw.writeBitsSigned(sample, this->bits_per_sample); prev.push_back(sample); } - for (unsigned int col = 1; col < this->columns; ++col) - { - for (unsigned int i = 0; i < this->samples_per_pixel; ++i) - { + for (unsigned int col = 1; col < this->columns; ++col) { + for (unsigned int i = 0; i < this->samples_per_pixel; ++i) { long long sample = in.getBitsSigned(this->bits_per_sample); long long new_sample = sample; - if (action == a_encode) - { + if (action == a_encode) { new_sample -= prev[i]; prev[i] = sample; - } - else - { + } else { new_sample += prev[i]; prev[i] = new_sample; } @@ -114,8 +108,7 @@ Pl_TIFFPredictor::processRow() void Pl_TIFFPredictor::finish() { - if (this->pos) - { + if (this->pos) { // write partial row processRow(); } |