summaryrefslogtreecommitdiff
path: root/source/fitz/compressed-buffer.c
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2014-03-14 20:01:32 +0000
committerRobin Watts <robin.watts@artifex.com>2014-03-18 17:48:40 +0000
commit4c2715a0bcecfed6ebdfee901920631b09364d7e (patch)
treeb0e5aa723719159a779425329ddc6ce48b8af0ce /source/fitz/compressed-buffer.c
parent551de42088c58dc69fba06fb53e36c2ddb12367f (diff)
downloadmupdf-4c2715a0bcecfed6ebdfee901920631b09364d7e.tar.xz
Fix operator buffering of inline images.
Previously pdf_process buffer did not understand inline images. In order to make this work without needlessly duplicating complex code from within pdf-op-run, the parsing of inline images has been moved to happen in pdf-interpret.c. When the op_table entry for BI is called it now expects the inline image to be in csi->img and the dictionary object to be in csi->obj. To make this work, we have had to improve the handling of inline images in general. While non-inline images have been loaded and held in memory in their compressed form and only decoded when required, until now we have always loaded and decoded inline images immediately. This has been due to the difficulty in knowing how many bytes of data to read from the stream - we know the length of the stream once uncompressed, but relating this to the compressed length is hard. To cure this we introduce a new type of filter stream, a 'leecher'. We insert a leecher stream before we build the filters required to decode the image. We then read and discard the appropriate number of uncompressed bytes from the filters. This pulls the compressed data through the leecher stream, which stores it in an fz_buffer. Thus images are now always held in their compressed forms in memory. The pdf-op-run implementation is now trivial. The only real complexity in the pdf-op-buffer implementation is the need to ensure that the /Filter entry in the dictionary object matches the exact point at which we backstopped the decompression.
Diffstat (limited to 'source/fitz/compressed-buffer.c')
-rw-r--r--source/fitz/compressed-buffer.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/source/fitz/compressed-buffer.c b/source/fitz/compressed-buffer.c
index e62feee0..b25709d9 100644
--- a/source/fitz/compressed-buffer.c
+++ b/source/fitz/compressed-buffer.c
@@ -14,11 +14,16 @@ fz_free_compressed_buffer(fz_context *ctx, fz_compressed_buffer *buf)
}
fz_stream *
-fz_open_image_decomp_stream(fz_context *ctx, fz_compressed_buffer *buffer, int *l2factor)
+fz_open_image_decomp_stream_from_buffer(fz_context *ctx, fz_compressed_buffer *buffer, int *l2factor)
{
fz_stream *chain = fz_open_buffer(ctx, buffer->buffer);
- fz_compression_params *params = &buffer->params;
+ return fz_open_image_decomp_stream(ctx, chain, &buffer->params, l2factor);
+}
+
+fz_stream *
+fz_open_image_decomp_stream(fz_context *ctx, fz_stream *chain, fz_compression_params *params, int *l2factor)
+{
switch (params->type)
{
case FZ_IMAGE_FAX:
@@ -63,7 +68,7 @@ fz_open_compressed_buffer(fz_context *ctx, fz_compressed_buffer *buffer)
{
int l2factor = 0;
- return fz_open_image_decomp_stream(ctx, buffer, &l2factor);
+ return fz_open_image_decomp_stream_from_buffer(ctx, buffer, &l2factor);
}
unsigned int