[poppler] Fix for my fix
Kristian Høgsberg
krh at bitplanet.net
Tue Aug 2 03:42:27 EST 2005
Albert Astals Cid wrote:
> Ok, there's the corrected patch, agree to commit?
Yep, that's exactly what I was thinking of. Please commit.
Thanks,
Kristian
> Albert
>
> A Dilluns 01 Agost 2005 16:52, vàreu escriure:
>
>>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 1 Aug 2005 16:46:12 -0000
>>>@@ -15,7 +15,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 (src->index == 0) {
>>>+ src->buffer = 0xFF;
>>>+ src->index++;
>>>+ }
>>>+ else if (src->index == 1) {
>>>+ src->buffer = 0xD8;
>>>+ src->index++;
>>>+ }
>>>+ else src->buffer = src->str->getChar();
>>> src->pub.next_input_byte = &src->buffer;
>>> src->pub.bytes_in_buffer = 1;
>>> return TRUE;
>>>@@ -50,6 +58,7 @@
>>> src.pub.bytes_in_buffer = 0;
>>> src.pub.next_input_byte = NULL;
>>> src.str = str;
>>>+ src.index = 0;
>>> cinfo.src = (jpeg_source_mgr *)&src;
>>> cinfo.err = jpeg_std_error(&jerr);
>>> x = 0;
>>>@@ -98,10 +107,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);
>>>
>>>Index: poppler/DCTStream.h
>>>===================================================================
>>>RCS file: /cvs/poppler/poppler/poppler/DCTStream.h,v
>>>retrieving revision 1.3
>>>diff -u -r1.3 DCTStream.h
>>>--- poppler/DCTStream.h 3 Apr 2005 18:17:55 -0000 1.3
>>>+++ poppler/DCTStream.h 1 Aug 2005 16:46:12 -0000
>>>@@ -45,6 +45,7 @@
>>> struct jpeg_source_mgr pub;
>>> JOCTET buffer;
>>> Stream *str;
>>>+ int index;
>>> };
>>>
>>>
>>>
>>>
>>>------------------------------------------------------------------------
>>>
>>>_______________________________________________
>>>poppler mailing list
>>>poppler at lists.freedesktop.org
>>>http://lists.freedesktop.org/mailman/listinfo/poppler
More information about the poppler
mailing list