diff options
author | Jay Berkenbilt <ejb@ql.org> | 2017-08-19 01:52:53 +0200 |
---|---|---|
committer | Jay Berkenbilt <ejb@ql.org> | 2017-08-21 23:44:02 +0200 |
commit | ae90d2c485318beb8b4b938d09ffaf5c6f0a5e21 (patch) | |
tree | 3d8bd3f2b0337693621b3ed97d1a906dbf3298b7 /libtests/dct_uncompress.cc | |
parent | 39ab004336188e53022f5345062e61639744335d (diff) | |
download | qpdf-ae90d2c485318beb8b4b938d09ffaf5c6f0a5e21.tar.zst |
Implement Pl_DCT pipeline
Additional testing is added in later commits to be supported by
additional changes in the library.
Diffstat (limited to 'libtests/dct_uncompress.cc')
-rw-r--r-- | libtests/dct_uncompress.cc | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/libtests/dct_uncompress.cc b/libtests/dct_uncompress.cc new file mode 100644 index 00000000..1ab1ae21 --- /dev/null +++ b/libtests/dct_uncompress.cc @@ -0,0 +1,44 @@ +#include <qpdf/Pl_DCT.hh> +#include <qpdf/Pl_StdioFile.hh> +#include <qpdf/QUtil.hh> + +#include <stdio.h> +#include <string.h> +#include <iostream> +#include <stdlib.h> + +int main(int argc, char* argv[]) +{ + if (argc != 3) + { + std::cerr << "Usage: dct_uncompress infile outfile" + << std::endl; + exit(2); + } + + char* infilename = argv[1]; + char* outfilename = argv[2]; + + FILE* infile = QUtil::safe_fopen(infilename, "rb"); + FILE* outfile = QUtil::safe_fopen(outfilename, "wb"); + Pl_StdioFile out("stdout", outfile); + unsigned char buf[100]; + bool done = false; + Pl_DCT dct("dct", &out); + while (! done) + { + size_t len = fread(buf, 1, sizeof(buf), infile); + if (len <= 0) + { + done = true; + } + else + { + dct.write(buf, len); + } + } + dct.finish(); + fclose(infile); + fclose(outfile); + return 0; +} |