diff options
Diffstat (limited to 'libqpdf/SF_FlateLzwDecode.cc')
-rw-r--r-- | libqpdf/SF_FlateLzwDecode.cc | 94 |
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); } |