Add linearization to pdf_write function.

Extend mupdfclean to have a new -l file that writes the file
linearized. This should still be considered experimental

When writing a pdf file, analyse object use, flatten resource use,
reorder the objects, generate a hintstream and output with linearisaton
parameters.

This is enough for Acrobat to accept the file as being optimised
for Fast Web View. We ought to add more tables to the hintstream
in some cases, but I doubt anyone actually uses it, the spec is so
badly written. Certainly acrobat accepts the file as being optimised
for 'Fast Web View'.

Update fz_dict_put to allow for us adding a reference to the dictionary
that is the sole owner of that reference already (i.e. don't drop then
keep something that has a reference count of just 1).

Update pdf_load_image_stream to use the stm_buf from the xref if there
is one.

Update pdf_close_document to discard any stm_bufs it may be holding.

Update fz_dict_put to be pdf_dict_put - this was missed in a renaming
ages ago and has been inconsistent since.
Fix Bug 693097; memory overwrite when handling knockout groups.

When handling knockout groups, we have to copy the background from the
previous group in so we can 'knockout' properly. If the previous group
is a different colorspace, this gives us problems!

The fix, implemented here, is to update the copy_pixmap_rect function
to know how to copy between pixmaps of different depth.

Gray <-> RGB are the ones we really care about; the generic code will
probably do a horrible job, but shouldn't ever be called at present.

This suffices to stop the crashing - we will probably revisit this
when we revise the blending support.
Fix Bug 693099: Render failure due to corrupt jpeg data.

The file supplied with the bug contains corrupt jpeg data on page
61. This causes an error to be thrown which results in mudraw
exiting.

Previously, when image decode was done at loading time, the error
would have been thrown under the pdf interpreter rather than under
the display list renderer. This error would have been caught, a
warning given, and the program would have continued. This is not
ideal behaviour, as there is no way for a caller to know that there
was a problem, and that the image is potentially incomplete.

The solution adopted here, solves both these problems. The fz_cookie
structure is expanded to include a 'errors' count. Whenever we meet
an error during rendering, we increment the 'errors' count, and
continue.

This enables applications to spot the errors count being non-zero on
exit and to display a warning.

mupdf is updated here to pass a cookie in and to check the error count
at the end; if it is found to be non zero, then a warning is given (just
once per visit to each page) to say that the page may have errors on it.
Fix Bug 693102: Overflows in large pixmap indexing.

When we allocate a pixmap > 2G, but < 4G, the index into that
pixmap, when calculated as an int can be negative. Fix this with
various casts to unsigned int.

If we ever move to support >4G images we'll need to rejig the
casting to cast each part of the element to ptrdiff_t first.
Move to using sigsetjmp/siglongjmp on more platforms.

Previously we used to have a special case hack in for MacOS. Now
we call sigsetjmp/siglongjmp on all platforms that define __unix.
(i.e. pretty much all of them except windows).
Followup to commit 120dadb; improved error handling during interpretation.

After commit 120dadb, it's far too easy to get into a seemingly infinite
loop while processing a corrupt file.

We fix this by changing the process to abort when we receive an invalid
keyword.

Also, we add another layer of nesting to pdf_run_stream to avoid us
push/popping an fz_try level on every keyword.
Change mudraw to set the error code if rendering errors present.

Make mudraw pass a cookie in to the rendering procedures. If any errors
are reported for any page, remember this, and set the return code to 1
on exit.
Android app: build safe AsyncTask behaviour into a derived class
Remove use of uninialized context.

Harmless, since the context wasn't used, but confusing.
A few general utility functions added for the sake of the forms work
Android app: explicitly release resources when page moves out of cache area
Remove unnecessary function and improve naming
Make backspace go to the previous page in x11 viewer.
Tweak pdf_new_{rect,matrix,xobject} to avoid warnings.

These functions currently call pdf_array_put, but this fails to
extend the array. Change to use pdf_array_push instead.
Support UserUnit for scaling PDF pages.
Scale page size by UserUnit in pdfinfo.
Fix indentation and white space errors.
Fix a char vs unsigned char warning.
Rework pdf_lexbuf to allow for dynamic parsing buffers.

Currently pdf_lexbufs use a static scratch buffer for parsing. In
the main case this is 64K in size, but in other cases it can be
just 256 bytes; this causes problems when parsing long strings.

Even the 64K limit is an implementation limit of Acrobat, not an
architectural limit of PDF.

Change here to allow dynamic buffers. This means a slightly more
complex setup and destruction for each buffer, but more importantly
requires correct cleanup on errors. To avoid having to insert
lots more try/catch clauses this commit includes various changes to
the code so we reuse pdf_lexbufs where possible. This keeps the
speed up.
Add make target to only build thirdparty

This makes it easier to separate building of mupdf itself from
libraries, e.g. when running clang's scan-build.