Commit ec0087e3ce2ae7554098b3506378ca3eb9d87795
1 parent
53971d50
Support TIFF Predictor (fixes #171)
Showing
6 changed files
with
38 additions
and
9 deletions
ChangeLog
| 1 | +2018-01-13 Jay Berkenbilt <ejb@ql.org> | ||
| 2 | + | ||
| 3 | + * Add support for TIFF predictor for LZW and Flate streams. Now | ||
| 4 | + all predictor functions are supported. | ||
| 5 | + | ||
| 1 | 2017-12-25 Jay Berkenbilt <ejb@ql.org> | 6 | 2017-12-25 Jay Berkenbilt <ejb@ql.org> |
| 2 | 7 | ||
| 3 | * Clarify documentation around options that control parsing but | 8 | * Clarify documentation around options that control parsing but |
libqpdf/QPDF_Stream.cc
| @@ -4,6 +4,7 @@ | @@ -4,6 +4,7 @@ | ||
| 4 | #include <qpdf/Pipeline.hh> | 4 | #include <qpdf/Pipeline.hh> |
| 5 | #include <qpdf/Pl_Flate.hh> | 5 | #include <qpdf/Pl_Flate.hh> |
| 6 | #include <qpdf/Pl_PNGFilter.hh> | 6 | #include <qpdf/Pl_PNGFilter.hh> |
| 7 | +#include <qpdf/Pl_TIFFPredictor.hh> | ||
| 7 | #include <qpdf/Pl_RC4.hh> | 8 | #include <qpdf/Pl_RC4.hh> |
| 8 | #include <qpdf/Pl_Buffer.hh> | 9 | #include <qpdf/Pl_Buffer.hh> |
| 9 | #include <qpdf/Pl_ASCII85Decoder.hh> | 10 | #include <qpdf/Pl_ASCII85Decoder.hh> |
| @@ -133,7 +134,7 @@ QPDF_Stream::understandDecodeParams( | @@ -133,7 +134,7 @@ QPDF_Stream::understandDecodeParams( | ||
| 133 | if (predictor_obj.isInteger()) | 134 | if (predictor_obj.isInteger()) |
| 134 | { | 135 | { |
| 135 | predictor = predictor_obj.getIntValue(); | 136 | predictor = predictor_obj.getIntValue(); |
| 136 | - if (! ((predictor == 1) || | 137 | + if (! ((predictor == 1) || (predictor == 2) || |
| 137 | ((predictor >= 10) && (predictor <= 15)))) | 138 | ((predictor >= 10) && (predictor <= 15)))) |
| 138 | { | 139 | { |
| 139 | filterable = false; | 140 | filterable = false; |
| @@ -459,14 +460,24 @@ QPDF_Stream::pipeStreamData(Pipeline* pipeline, | @@ -459,14 +460,24 @@ QPDF_Stream::pipeStreamData(Pipeline* pipeline, | ||
| 459 | { | 460 | { |
| 460 | std::string const& filter = *iter; | 461 | std::string const& filter = *iter; |
| 461 | 462 | ||
| 462 | - if (((filter == "/FlateDecode") || (filter == "/LZWDecode")) && | ||
| 463 | - ((predictor >= 10) && (predictor <= 15))) | 463 | + if ((filter == "/FlateDecode") || (filter == "/LZWDecode")) |
| 464 | { | 464 | { |
| 465 | - QTC::TC("qpdf", "QPDF_Stream PNG filter"); | ||
| 466 | - pipeline = new Pl_PNGFilter( | ||
| 467 | - "png decode", pipeline, Pl_PNGFilter::a_decode, | ||
| 468 | - columns, colors, bits_per_component); | ||
| 469 | - to_delete.push_back(pipeline); | 465 | + if ((predictor >= 10) && (predictor <= 15)) |
| 466 | + { | ||
| 467 | + QTC::TC("qpdf", "QPDF_Stream PNG filter"); | ||
| 468 | + pipeline = new Pl_PNGFilter( | ||
| 469 | + "png decode", pipeline, Pl_PNGFilter::a_decode, | ||
| 470 | + columns, colors, bits_per_component); | ||
| 471 | + to_delete.push_back(pipeline); | ||
| 472 | + } | ||
| 473 | + else if (predictor == 2) | ||
| 474 | + { | ||
| 475 | + QTC::TC("qpdf", "QPDF_Stream TIFF predictor"); | ||
| 476 | + pipeline = new Pl_TIFFPredictor( | ||
| 477 | + "tiff decode", pipeline, Pl_TIFFPredictor::a_decode, | ||
| 478 | + columns, colors, bits_per_component); | ||
| 479 | + to_delete.push_back(pipeline); | ||
| 480 | + } | ||
| 470 | } | 481 | } |
| 471 | 482 | ||
| 472 | if (filter == "/Crypt") | 483 | if (filter == "/Crypt") |
qpdf/qpdf.testcov
| @@ -301,3 +301,4 @@ qpdf-c called qpdf_set_decode_level 0 | @@ -301,3 +301,4 @@ qpdf-c called qpdf_set_decode_level 0 | ||
| 301 | qpdf-c called qpdf_set_compress_streams 0 | 301 | qpdf-c called qpdf_set_compress_streams 0 |
| 302 | qpdf-c called qpdf_set_preserve_unreferenced_objects 0 | 302 | qpdf-c called qpdf_set_preserve_unreferenced_objects 0 |
| 303 | qpdf-c called qpdf_set_newline_before_endstream 0 | 303 | qpdf-c called qpdf_set_newline_before_endstream 0 |
| 304 | +QPDF_Stream TIFF predictor 0 |
qpdf/qtest/qpdf.test
| @@ -240,7 +240,7 @@ foreach my $d (@bug_tests) | @@ -240,7 +240,7 @@ foreach my $d (@bug_tests) | ||
| 240 | show_ntests(); | 240 | show_ntests(); |
| 241 | # ---------- | 241 | # ---------- |
| 242 | $td->notify("--- Miscellaneous Tests ---"); | 242 | $td->notify("--- Miscellaneous Tests ---"); |
| 243 | -$n_tests += 86; | 243 | +$n_tests += 87; |
| 244 | 244 | ||
| 245 | $td->runtest("qpdf version", | 245 | $td->runtest("qpdf version", |
| 246 | {$td->COMMAND => "qpdf --version"}, | 246 | {$td->COMMAND => "qpdf --version"}, |
| @@ -684,6 +684,12 @@ $td->runtest("short /O or /U", | @@ -684,6 +684,12 @@ $td->runtest("short /O or /U", | ||
| 684 | $td->EXIT_STATUS => 0}, | 684 | $td->EXIT_STATUS => 0}, |
| 685 | $td->NORMALIZE_NEWLINES); | 685 | $td->NORMALIZE_NEWLINES); |
| 686 | 686 | ||
| 687 | +$td->runtest("stream with tiff predictor", | ||
| 688 | + {$td->COMMAND => "qpdf --check tiff-predictor.pdf"}, | ||
| 689 | + {$td->FILE => "tiff-predictor.out", | ||
| 690 | + $td->EXIT_STATUS => 0}, | ||
| 691 | + $td->NORMALIZE_NEWLINES); | ||
| 692 | + | ||
| 687 | show_ntests(); | 693 | show_ntests(); |
| 688 | # ---------- | 694 | # ---------- |
| 689 | $td->notify("--- Newline before endstream ---"); | 695 | $td->notify("--- Newline before endstream ---"); |
qpdf/qtest/qpdf/tiff-predictor.out
0 → 100644
qpdf/qtest/qpdf/tiff-predictor.pdf
0 → 100644
No preview for this file type