aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf/SF_FlateLzwDecode.cc
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2022-04-02 23:14:10 +0200
committerJay Berkenbilt <ejb@ql.org>2022-04-04 14:10:40 +0200
commit12f1eb15ca3fed6310402847559a7c99d3c77847 (patch)
tree8935675b623c6f3b4914b8b44f7fa5f2816a9241 /libqpdf/SF_FlateLzwDecode.cc
parentf20fa61eb4c323eb1642c69c236b3d9a1f8b2cdb (diff)
downloadqpdf-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/SF_FlateLzwDecode.cc')
-rw-r--r--libqpdf/SF_FlateLzwDecode.cc94
1 files changed, 33 insertions, 61 deletions
diff --git a/libqpdf/SF_FlateLzwDecode.cc b/libqpdf/SF_FlateLzwDecode.cc
index 196cbded..f753ffd8 100644
--- a/libqpdf/SF_FlateLzwDecode.cc
+++ b/libqpdf/SF_FlateLzwDecode.cc
@@ -1,11 +1,11 @@
#include <qpdf/SF_FlateLzwDecode.hh>
-#include <qpdf/Pl_PNGFilter.hh>
-#include <qpdf/Pl_TIFFPredictor.hh>
#include <qpdf/Pl_Flate.hh>
#include <qpdf/Pl_LZWDecoder.hh>
-#include <qpdf/QTC.hh>
+#include <qpdf/Pl_PNGFilter.hh>
+#include <qpdf/Pl_TIFFPredictor.hh>
#include <qpdf/QIntC.hh>
+#include <qpdf/QTC.hh>
SF_FlateLzwDecode::SF_FlateLzwDecode(bool lzw) :
lzw(lzw),
@@ -21,105 +21,80 @@ SF_FlateLzwDecode::SF_FlateLzwDecode(bool lzw) :
bool
SF_FlateLzwDecode::setDecodeParms(QPDFObjectHandle decode_parms)
{
- if (decode_parms.isNull())
- {
+ if (decode_parms.isNull()) {
return true;
}
bool filterable = true;
std::set<std::string> keys = decode_parms.getKeys();
- for (auto const& key: keys)
- {
+ for (auto const& key : keys) {
QPDFObjectHandle value = decode_parms.getKey(key);
- if (key == "/Predictor")
- {
- if (value.isInteger())
- {
+ if (key == "/Predictor") {
+ if (value.isInteger()) {
this->predictor = value.getIntValueAsInt();
- if (! ((this->predictor == 1) || (this->predictor == 2) ||
- ((this->predictor >= 10) && (this->predictor <= 15))))
- {
+ if (!((this->predictor == 1) || (this->predictor == 2) ||
+ ((this->predictor >= 10) && (this->predictor <= 15)))) {
filterable = false;
}
- }
- else
- {
+ } else {
filterable = false;
}
- }
- else if ((key == "/Columns") ||
- (key == "/Colors") ||
- (key == "/BitsPerComponent"))
- {
- if (value.isInteger())
- {
+ } else if (
+ (key == "/Columns") || (key == "/Colors") ||
+ (key == "/BitsPerComponent")) {
+ if (value.isInteger()) {
int val = value.getIntValueAsInt();
- if (key == "/Columns")
- {
+ if (key == "/Columns") {
this->columns = val;
- }
- else if (key == "/Colors")
- {
+ } else if (key == "/Colors") {
this->colors = val;
- }
- else if (key == "/BitsPerComponent")
- {
+ } else if (key == "/BitsPerComponent") {
this->bits_per_component = val;
}
- }
- else
- {
+ } else {
filterable = false;
}
- }
- else if (lzw && (key == "/EarlyChange"))
- {
- if (value.isInteger())
- {
+ } else if (lzw && (key == "/EarlyChange")) {
+ if (value.isInteger()) {
int earlychange = value.getIntValueAsInt();
this->early_code_change = (earlychange == 1);
- if (! ((earlychange == 0) || (earlychange == 1)))
- {
+ if (!((earlychange == 0) || (earlychange == 1))) {
filterable = false;
}
- }
- else
- {
+ } else {
filterable = false;
}
}
}
- if ((this->predictor > 1) && (this->columns == 0))
- {
+ if ((this->predictor > 1) && (this->columns == 0)) {
filterable = false;
}
return filterable;
}
-
-
Pipeline*
SF_FlateLzwDecode::getDecodePipeline(Pipeline* next)
{
std::shared_ptr<Pipeline> pipeline;
- if ((this->predictor >= 10) && (this->predictor <= 15))
- {
+ if ((this->predictor >= 10) && (this->predictor <= 15)) {
QTC::TC("qpdf", "SF_FlateLzwDecode PNG filter");
pipeline = std::make_shared<Pl_PNGFilter>(
- "png decode", next, Pl_PNGFilter::a_decode,
+ "png decode",
+ next,
+ Pl_PNGFilter::a_decode,
QIntC::to_uint(this->columns),
QIntC::to_uint(this->colors),
QIntC::to_uint(this->bits_per_component));
this->pipelines.push_back(pipeline);
next = pipeline.get();
- }
- else if (this->predictor == 2)
- {
+ } else if (this->predictor == 2) {
QTC::TC("qpdf", "SF_FlateLzwDecode TIFF predictor");
pipeline = std::make_shared<Pl_TIFFPredictor>(
- "tiff decode", next, Pl_TIFFPredictor::a_decode,
+ "tiff decode",
+ next,
+ Pl_TIFFPredictor::a_decode,
QIntC::to_uint(this->columns),
QIntC::to_uint(this->colors),
QIntC::to_uint(this->bits_per_component));
@@ -127,13 +102,10 @@ SF_FlateLzwDecode::getDecodePipeline(Pipeline* next)
next = pipeline.get();
}
- if (lzw)
- {
+ if (lzw) {
pipeline = std::make_shared<Pl_LZWDecoder>(
"lzw decode", next, early_code_change);
- }
- else
- {
+ } else {
pipeline = std::make_shared<Pl_Flate>(
"stream inflate", next, Pl_Flate::a_inflate);
}