2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-12-22 10:58:58 +00:00

Support TIFF Predictor (fixes #171)

This commit is contained in:
Jay Berkenbilt 2018-01-13 14:24:09 -05:00
parent 53971d50be
commit ec0087e3ce
6 changed files with 38 additions and 9 deletions

View File

@ -1,3 +1,8 @@
2018-01-13 Jay Berkenbilt <ejb@ql.org>
* Add support for TIFF predictor for LZW and Flate streams. Now
all predictor functions are supported.
2017-12-25 Jay Berkenbilt <ejb@ql.org> 2017-12-25 Jay Berkenbilt <ejb@ql.org>
* Clarify documentation around options that control parsing but * Clarify documentation around options that control parsing but

View File

@ -4,6 +4,7 @@
#include <qpdf/Pipeline.hh> #include <qpdf/Pipeline.hh>
#include <qpdf/Pl_Flate.hh> #include <qpdf/Pl_Flate.hh>
#include <qpdf/Pl_PNGFilter.hh> #include <qpdf/Pl_PNGFilter.hh>
#include <qpdf/Pl_TIFFPredictor.hh>
#include <qpdf/Pl_RC4.hh> #include <qpdf/Pl_RC4.hh>
#include <qpdf/Pl_Buffer.hh> #include <qpdf/Pl_Buffer.hh>
#include <qpdf/Pl_ASCII85Decoder.hh> #include <qpdf/Pl_ASCII85Decoder.hh>
@ -133,7 +134,7 @@ QPDF_Stream::understandDecodeParams(
if (predictor_obj.isInteger()) if (predictor_obj.isInteger())
{ {
predictor = predictor_obj.getIntValue(); predictor = predictor_obj.getIntValue();
if (! ((predictor == 1) || if (! ((predictor == 1) || (predictor == 2) ||
((predictor >= 10) && (predictor <= 15)))) ((predictor >= 10) && (predictor <= 15))))
{ {
filterable = false; filterable = false;
@ -459,14 +460,24 @@ QPDF_Stream::pipeStreamData(Pipeline* pipeline,
{ {
std::string const& filter = *iter; std::string const& filter = *iter;
if (((filter == "/FlateDecode") || (filter == "/LZWDecode")) && if ((filter == "/FlateDecode") || (filter == "/LZWDecode"))
((predictor >= 10) && (predictor <= 15)))
{ {
QTC::TC("qpdf", "QPDF_Stream PNG filter"); if ((predictor >= 10) && (predictor <= 15))
pipeline = new Pl_PNGFilter( {
"png decode", pipeline, Pl_PNGFilter::a_decode, QTC::TC("qpdf", "QPDF_Stream PNG filter");
columns, colors, bits_per_component); pipeline = new Pl_PNGFilter(
to_delete.push_back(pipeline); "png decode", pipeline, Pl_PNGFilter::a_decode,
columns, colors, bits_per_component);
to_delete.push_back(pipeline);
}
else if (predictor == 2)
{
QTC::TC("qpdf", "QPDF_Stream TIFF predictor");
pipeline = new Pl_TIFFPredictor(
"tiff decode", pipeline, Pl_TIFFPredictor::a_decode,
columns, colors, bits_per_component);
to_delete.push_back(pipeline);
}
} }
if (filter == "/Crypt") if (filter == "/Crypt")

View File

@ -301,3 +301,4 @@ qpdf-c called qpdf_set_decode_level 0
qpdf-c called qpdf_set_compress_streams 0 qpdf-c called qpdf_set_compress_streams 0
qpdf-c called qpdf_set_preserve_unreferenced_objects 0 qpdf-c called qpdf_set_preserve_unreferenced_objects 0
qpdf-c called qpdf_set_newline_before_endstream 0 qpdf-c called qpdf_set_newline_before_endstream 0
QPDF_Stream TIFF predictor 0

View File

@ -240,7 +240,7 @@ foreach my $d (@bug_tests)
show_ntests(); show_ntests();
# ---------- # ----------
$td->notify("--- Miscellaneous Tests ---"); $td->notify("--- Miscellaneous Tests ---");
$n_tests += 86; $n_tests += 87;
$td->runtest("qpdf version", $td->runtest("qpdf version",
{$td->COMMAND => "qpdf --version"}, {$td->COMMAND => "qpdf --version"},
@ -684,6 +684,12 @@ $td->runtest("short /O or /U",
$td->EXIT_STATUS => 0}, $td->EXIT_STATUS => 0},
$td->NORMALIZE_NEWLINES); $td->NORMALIZE_NEWLINES);
$td->runtest("stream with tiff predictor",
{$td->COMMAND => "qpdf --check tiff-predictor.pdf"},
{$td->FILE => "tiff-predictor.out",
$td->EXIT_STATUS => 0},
$td->NORMALIZE_NEWLINES);
show_ntests(); show_ntests();
# ---------- # ----------
$td->notify("--- Newline before endstream ---"); $td->notify("--- Newline before endstream ---");

View File

@ -0,0 +1,6 @@
checking tiff-predictor.pdf
PDF Version: 1.5
File is not encrypted
File is not linearized
No syntax or stream encoding errors found; the file may still contain
errors that qpdf cannot detect

Binary file not shown.