[poppler] Fix for my fix
Kristian Høgsberg
krh at bitplanet.net
Tue Aug 2 00:52:31 EST 2005
Albert Astals Cid wrote:
> Hi, this patch fixes a problem i have seen in a pdf (can not share it) where
> calling str->reset() to times in DCTStream::reset causes it to misbehave.
>
> To not call str->reset() and still skip the gargabe we find at the beginning
> of the stream, i've modified str_fill_input_buffer(...) so that in the two
> first cases it returns the JPEG markers and then the rest of the data (that
> will be after the garbage).
>
> Should the int be declared static? I'm sometimes lost with static when it does
> not apply to classes.
>
> What do you think?
The idea of the patch is good, but the integer counter must be part of
struct str_src_mgr, declared in DCTStream.h and initialized in the
DCTStream constructor. With the current global variable, there's only
one 'i' in the entire program and if you have two DCTStreams in a
document, only the first one will work.
>
> Albert
>
>
> ------------------------------------------------------------------------
>
> Index: poppler/DCTStream.cc
> ===================================================================
> RCS file: /cvs/poppler/poppler/poppler/DCTStream.cc,v
> retrieving revision 1.2
> diff -u -r1.2 DCTStream.cc
> --- poppler/DCTStream.cc 25 Jul 2005 20:40:37 -0000 1.2
> +++ poppler/DCTStream.cc 30 Jul 2005 21:11:29 -0000
> @@ -8,6 +8,8 @@
>
> #include "DCTStream.h"
>
> +int i = 0;
> +
> static void str_init_source(j_decompress_ptr cinfo)
> {
> }
> @@ -15,7 +17,15 @@
> static boolean str_fill_input_buffer(j_decompress_ptr cinfo)
> {
> struct str_src_mgr * src = (struct str_src_mgr *)cinfo->src;
> - src->buffer = src->str->getChar();
> + if (i == 0) {
> + src->buffer = 0xFF;
> + i++;
> + }
> + else if (i == 1) {
> + src->buffer = 0xD8;
> + i++;
> + }
> + else src->buffer = src->str->getChar();
> src->pub.next_input_byte = &src->buffer;
> src->pub.bytes_in_buffer = 1;
> return TRUE;
> @@ -98,10 +108,6 @@
> n++;
> }
>
> - // ...and this skips the garbage
> - str->reset();
> - for (n = n - 2; n > 0; n--) str->getChar();
> -
> jpeg_read_header(&cinfo, TRUE);
> jpeg_start_decompress(&cinfo);
>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> poppler mailing list
> poppler at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/poppler
More information about the poppler
mailing list