Commit a8631e255e4607cec86986576a7d52dccf81e916
1 parent
2b470ff7
Code tidy SF_FlateLzwDecode
Showing
4 changed files
with
26 additions
and
30 deletions
.git-blame-ignore-revs
libqpdf/QPDFJob_argv.cc
| ... | ... | @@ -117,8 +117,10 @@ ArgParser::argZopfli() |
| 117 | 117 | logger->info("Set the environment variable QPDF_ZOPFLI to activate.\n"); |
| 118 | 118 | logger->info("* QPDF_ZOPFLI=disabled or QPDF_ZOPFLI not set: don't use zopfli.\n"); |
| 119 | 119 | logger->info("* QPDF_ZOPFLI=force: use zopfli, and fail if not available.\n"); |
| 120 | - logger->info("* QPDF_ZOPFLI=silent: use zopfli if available and silently fall back if not.\n"); | |
| 121 | - logger->info("* QPDF_ZOPFLI= any other value: use zopfli if available, and warn if not.\n"); | |
| 120 | + logger->info( | |
| 121 | + "* QPDF_ZOPFLI=silent: use zopfli if available and silently fall back if not.\n"); | |
| 122 | + logger->info( | |
| 123 | + "* QPDF_ZOPFLI= any other value: use zopfli if available, and warn if not.\n"); | |
| 122 | 124 | } |
| 123 | 125 | } else { |
| 124 | 126 | logger->error("zopfli support is not enabled\n"); | ... | ... |
libqpdf/SF_FlateLzwDecode.cc
| ... | ... | @@ -7,17 +7,6 @@ |
| 7 | 7 | #include <qpdf/QIntC.hh> |
| 8 | 8 | #include <qpdf/QTC.hh> |
| 9 | 9 | |
| 10 | -SF_FlateLzwDecode::SF_FlateLzwDecode(bool lzw) : | |
| 11 | - lzw(lzw), | |
| 12 | - // Initialize values to their defaults as per the PDF spec | |
| 13 | - predictor(1), | |
| 14 | - columns(1), | |
| 15 | - colors(1), | |
| 16 | - bits_per_component(8), | |
| 17 | - early_code_change(true) | |
| 18 | -{ | |
| 19 | -} | |
| 20 | - | |
| 21 | 10 | bool |
| 22 | 11 | SF_FlateLzwDecode::setDecodeParms(QPDFObjectHandle decode_parms) |
| 23 | 12 | { |
| ... | ... | @@ -32,14 +21,13 @@ SF_FlateLzwDecode::setDecodeParms(QPDFObjectHandle decode_parms) |
| 32 | 21 | if (key == "/Predictor") { |
| 33 | 22 | if (value.isInteger()) { |
| 34 | 23 | predictor = value.getIntValueAsInt(); |
| 35 | - if (!((predictor == 1) || (predictor == 2) || | |
| 36 | - ((predictor >= 10) && (predictor <= 15)))) { | |
| 24 | + if (!(predictor == 1 || predictor == 2 || (predictor >= 10 && predictor <= 15))) { | |
| 37 | 25 | filterable = false; |
| 38 | 26 | } |
| 39 | 27 | } else { |
| 40 | 28 | filterable = false; |
| 41 | 29 | } |
| 42 | - } else if ((key == "/Columns") || (key == "/Colors") || (key == "/BitsPerComponent")) { | |
| 30 | + } else if (key == "/Columns" || key == "/Colors" || key == "/BitsPerComponent") { | |
| 43 | 31 | if (value.isInteger()) { |
| 44 | 32 | int val = value.getIntValueAsInt(); |
| 45 | 33 | if (key == "/Columns") { |
| ... | ... | @@ -56,7 +44,7 @@ SF_FlateLzwDecode::setDecodeParms(QPDFObjectHandle decode_parms) |
| 56 | 44 | if (value.isInteger()) { |
| 57 | 45 | int earlychange = value.getIntValueAsInt(); |
| 58 | 46 | early_code_change = (earlychange == 1); |
| 59 | - if (!((earlychange == 0) || (earlychange == 1))) { | |
| 47 | + if (!(earlychange == 0 || earlychange == 1)) { | |
| 60 | 48 | filterable = false; |
| 61 | 49 | } |
| 62 | 50 | } else { |
| ... | ... | @@ -65,7 +53,7 @@ SF_FlateLzwDecode::setDecodeParms(QPDFObjectHandle decode_parms) |
| 65 | 53 | } |
| 66 | 54 | } |
| 67 | 55 | |
| 68 | - if ((predictor > 1) && (columns == 0)) { | |
| 56 | + if (predictor > 1 && columns == 0) { | |
| 69 | 57 | filterable = false; |
| 70 | 58 | } |
| 71 | 59 | |
| ... | ... | @@ -76,7 +64,7 @@ Pipeline* |
| 76 | 64 | SF_FlateLzwDecode::getDecodePipeline(Pipeline* next) |
| 77 | 65 | { |
| 78 | 66 | std::shared_ptr<Pipeline> pipeline; |
| 79 | - if ((predictor >= 10) && (predictor <= 15)) { | |
| 67 | + if (predictor >= 10 && predictor <= 15) { | |
| 80 | 68 | QTC::TC("qpdf", "SF_FlateLzwDecode PNG filter"); |
| 81 | 69 | pipeline = std::make_shared<Pl_PNGFilter>( |
| 82 | 70 | "png decode", | ... | ... |
libqpdf/qpdf/SF_FlateLzwDecode.hh
| ... | ... | @@ -5,25 +5,29 @@ |
| 5 | 5 | #ifndef SF_FLATELZWDECODE_HH |
| 6 | 6 | # define SF_FLATELZWDECODE_HH |
| 7 | 7 | |
| 8 | -class SF_FlateLzwDecode: public QPDFStreamFilter | |
| 8 | +class SF_FlateLzwDecode final: public QPDFStreamFilter | |
| 9 | 9 | { |
| 10 | 10 | public: |
| 11 | - SF_FlateLzwDecode(bool lzw); | |
| 12 | - ~SF_FlateLzwDecode() override = default; | |
| 11 | + SF_FlateLzwDecode(bool lzw) : | |
| 12 | + lzw(lzw) | |
| 13 | + { | |
| 14 | + } | |
| 15 | + ~SF_FlateLzwDecode() final = default; | |
| 13 | 16 | |
| 14 | - bool setDecodeParms(QPDFObjectHandle decode_parms) override; | |
| 15 | - Pipeline* getDecodePipeline(Pipeline* next) override; | |
| 17 | + bool setDecodeParms(QPDFObjectHandle decode_parms) final; | |
| 18 | + Pipeline* getDecodePipeline(Pipeline* next) final; | |
| 16 | 19 | |
| 17 | 20 | static std::shared_ptr<QPDFStreamFilter> flate_factory(); |
| 18 | 21 | static std::shared_ptr<QPDFStreamFilter> lzw_factory(); |
| 19 | 22 | |
| 20 | 23 | private: |
| 21 | - bool lzw; | |
| 22 | - int predictor; | |
| 23 | - int columns; | |
| 24 | - int colors; | |
| 25 | - int bits_per_component; | |
| 26 | - bool early_code_change; | |
| 24 | + bool lzw{}; | |
| 25 | + // Defaults as per the PDF spec | |
| 26 | + int predictor{1}; | |
| 27 | + int columns{1}; | |
| 28 | + int colors{1}; | |
| 29 | + int bits_per_component{8}; | |
| 30 | + bool early_code_change{true}; | |
| 27 | 31 | std::vector<std::shared_ptr<Pipeline>> pipelines; |
| 28 | 32 | }; |
| 29 | 33 | ... | ... |